- Whenever a function is declared in JavaScript a closure is created.
- Returning a function from inside another function is the classsic example of closure: The state inside the outer function is imlpicitly available to the returned function even after the outer function has completed its execution.
- Check this link!
- In some programming languages, the local variables within a function exist for just the duration of that function's execution. This is not the case for JavaScript.
Check this too!
- JavaScript closures can emulate private methods.
No comments:
Post a Comment