DEV Community

Discussion on: What are Closures in JavaScript?

Collapse
 
tripol profile image
Ekanem • Edited

Thanks for the article. I have a question though. Why was the function returned when y instead of y() was called?

Collapse
 
naveenkamath profile image
Naveen Kamath

Because I wanted to return the function y and not to invoke or call it .
y-->returning function y.
y()--> Invoking or calling the function.

Collapse
 
tripol profile image
Ekanem

Thank you. I understand better now

Thread Thread
 
naveenkamath profile image
Naveen Kamath

Glad you liked it :)