why function puzzle could be call with ()() | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

why function puzzle could be call with ()()

function puzzle(){ return function(){ console.log(arguments); } } puzzle('a','b','c')(1,2,3);

28th Jul 2022, 9:34 AM
Luise Chen
Luise Chen - avatar
3 Answers
+ 2
Call the return of puzzle (which is a function) with arguments (1,2,3) Long form: Myfunc = puzzle() Myfunc(1,2,3) Welcome in the world of functional programming where functions are first class objects. It is a bootcamp for each brain at the beginning. But some guys are addicted to it.
28th Jul 2022, 10:05 AM
Oma Falk
Oma Falk - avatar
+ 1
Luise Chen 💯👍🏻
28th Jul 2022, 12:57 PM
Oma Falk
Oma Falk - avatar
0
@Oma Falk thanks, I got it, so the paremeters ('a','b','c') didn't pass to arguments in return. The function in return just take(1,2,3) as arguments
28th Jul 2022, 11:40 AM
Luise Chen
Luise Chen - avatar