Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are execution context and closure the same thing in JavaScript?

Tags:

javascript

I have read several tutorials about closures. Some tutorials have some information about execution context. I am confused that execution context and closure seem to the same thing.Does anyone can explain this?

like image 873
ChenLee Avatar asked Sep 27 '26 19:09

ChenLee


1 Answers

Closures are functions which remember the environment they were created in. https://developer.mozilla.org/en/docs/Web/JavaScript/Closures

Closures keep the reference to the lexical context where they are created. Check this to know more about lexical context: Lexical environment and function scope. When the closures(functions) are executed, they are executed in execution context. So,

Closures => function, Execution context => environment

like image 98
Asish Bhattarai Avatar answered Sep 29 '26 08:09

Asish Bhattarai



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!