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.
Thank you very much sir
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).
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
@@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.
@@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