DEV Community

Cover image for What are Closures in JavaScript?

What are Closures in JavaScript?

Naveen Kamath on December 11, 2021

Hello Readers, Keep Reading this Blog to know more about Closures .... Lets Look at this Example: 1. function x(){ 2. var a=14; 3. fu...
Collapse
 
adithyahere profile image
Adithya •

Short and clear blog buddy!👏

Collapse
 
naveenkamath profile image
Naveen Kamath •

Thank you :)

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 :)

Collapse
 
andrewbaisden profile image
Andrew Baisden •

Nice and concise 👍

Collapse
 
naveenkamath profile image
Naveen Kamath •

Thank you :)

Collapse
 
jamstra profile image
Jam Straw •

Nice Information.

Collapse
 
naveenkamath profile image
Naveen Kamath •

Ty and Have a Great Day :)

Collapse
 
jesusmdy profile image
Jesús Ramírez •

Clearest impossible!

Collapse
 
liamemma profile image
Liam Emma •

Good Information thanks

Collapse
 
naveenkamath profile image
Naveen Kamath • • Edited

Glad you Liked it :)

Collapse
 
lozio1992 profile image
lozio •

Thanks,it helps me a lot. Can I translate it into Chinese and share it to more people on juejin.im ?

Collapse
 
naveenkamath profile image
Naveen Kamath •

ok