๐Ÿ”ฐclosure

JS โŸฉ value โŸฉ function โŸฉ closure

A closure

  • is the combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment).

  • gives you access to an outer function's scope from an inner function.

  • is created every time a function is created, at function creation time.

๐Ÿ‘‰ lexical environment

see how a closure "closes over" outer lexical environments

Last updated