Function call call call …

We usually call a function by using a set on parenthesis after its name eg. fun()
but what if our function returned a function? In that case you would be able to call it again

function hello(){
console.log(“Hello”);
return () => console.l…


This content originally appeared on DEV Community and was authored by Shuvo

We usually call a function by using a set on parenthesis after its name eg. fun()
but what if our function returned a function? In that case you would be able to call it again

function hello(){
    console.log("Hello");
    return () => console.log(" world");
}
hello()();

It looks a lot normal if we use a variable in between

function hello(){
    console.log("Hello");
    return () => console.log(" world");
}
let func = hello(); //receiving the function returned from hello
func();

but in we try to call the function third time it will give us error.
function call error

but what if your function returned itself? in that case when ever we call it we are again getting a function returned so can can keep calling it infinitely

function hello(){
    console.log("Hello");
    return hello;
}
hello()()()()()()()()()()()();

Hope you enjoyed the article, for now cya()()()()()()


This content originally appeared on DEV Community and was authored by Shuvo


Print Share Comment Cite Upload Translate Updates
APA

Shuvo | Sciencx (2021-10-17T14:41:41+00:00) Function call call call …. Retrieved from https://www.scien.cx/2021/10/17/function-call-call-call/

MLA
" » Function call call call …." Shuvo | Sciencx - Sunday October 17, 2021, https://www.scien.cx/2021/10/17/function-call-call-call/
HARVARD
Shuvo | Sciencx Sunday October 17, 2021 » Function call call call …., viewed ,<https://www.scien.cx/2021/10/17/function-call-call-call/>
VANCOUVER
Shuvo | Sciencx - » Function call call call …. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/10/17/function-call-call-call/
CHICAGO
" » Function call call call …." Shuvo | Sciencx - Accessed . https://www.scien.cx/2021/10/17/function-call-call-call/
IEEE
" » Function call call call …." Shuvo | Sciencx [Online]. Available: https://www.scien.cx/2021/10/17/function-call-call-call/. [Accessed: ]
rf:citation
» Function call call call … | Shuvo | Sciencx | https://www.scien.cx/2021/10/17/function-call-call-call/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.