When people hear the word ‘Closure’ in programming, they think it has to do something with web development, especially JavaScript. But closures are not limited to JavaScript. They can be used in any language that supports first-class functions.

Closures are quite confusing entities in any programming language that supports them. It takes a while just to understand what they are, let alone use them to solve problems, but once understood, they can become a very powerful tool to use. You can log your functions, check how long they took to run, override variables from outer functions and a lot more.

But what exactly is a closure?

Well, simply put, a closure is an inner function that has access to variables created in an outer function to a degree by which it can store and manipulate it even after the outer function has finished executing.

Aniket Mishra

Core Team and Developer @Codezoned; Plays around with data and builds websites. Usually trying to perform magic tricks with the computer.

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