Good example of a closure in JavaScript

β€œThe inner function is said to have closure over the variable a”

Thanks for the article Nikhil Vijayan !!! This is a very clear way of putting it that I think gets lost in some of the discussion of closures.

Image for post

PS Your code samples would be a lot more readable if you copy-pasted them into Gists ( and then pasted the Gist link into Medium.

πŸ€“ The physical therapist who writes JavaScript πŸ’ͺ Web Developer 😎 Mentor 🧠 DPT πŸ˜„ SEO Expert 😁 React πŸ˜† Jamstack πŸ’¬ Ask me anything πŸ‘‰ πŸ‘ˆ

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store