DEV Community

Discussion on: JavaScript Tricky Outputs: Unveiling the Mysteries

Collapse
 
jonrandy profile image
Jon Randy 🎖️

A closure is created when a function is defined within another function and has access to its parent function’s variables.

Unfortunately, this isn't really correct. A closure is created EVERY time a function is created, regardless of whether it was inside another function. You also imply that a closure is a function - which is also incorrect.

Collapse
 
jaimaldullat profile image
Jaimal Dullat

Thanks @jonrandy ... I will update.