A closure is the combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment/scope) In JavaScript, closures are created every time a function is created, at function creation time. The concept of lexical scope can be an interview question on it’s own.

2m read timeFrom blog.devgenius.io
Post cover image
Table of contents
The term "lexical scope" may seem tricky to grasp at first glance. But it's helpful to understand what each word means…