JavaScript Function returning function

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 ก.ย. 2024
  • In previous lecture, we learnt that a function in JavaScript is a first class function i.e. it acts like any other value in JavaScript. We learned that a function can also be passed as a parameter to another function .
    In this lecture, we will understand, how to return a functions from another function and how to use it.

ความคิดเห็น • 5

  • @alexkiiru1283
    @alexkiiru1283 2 ปีที่แล้ว +1

    Thank you very much sir

  • @Martin958
    @Martin958 2 ปีที่แล้ว

    Is it necessary to write the -function- return keyword in each case? I thought the function would be automatically returned.
    (Sorry Error in question. I meant to ask why do you need the return keyword in each case, and not the 'function' keyword).

    • @edgarlorsch2555
      @edgarlorsch2555 ปีที่แล้ว

      I think it probably is since the function is returning a function data type, cause if we were to return string data, we would enclose our return data using opening and closing speech marks

    • @Martin958
      @Martin958 ปีที่แล้ว

      @@edgarlorsch2555 I think I meant to ask, 'Is it necessary to write the return keyword in each case?' Not the function keyword. I wondered why they were not implicitly returned. I have amended the question now.

    • @jakubnowak7091
      @jakubnowak7091 ปีที่แล้ว +2

      @@Martin958 yes, without return the function cannot return anything unless it's an one line arrow function. try to assign a function with and then without return, and then log both of them to the console to see the difference