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?
Asked
Active
Viewed 502 times
1 Answers
6
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

Community
- 1
- 1

Asish Bhattarai
- 482
- 1
- 4
- 13
-
I am confused by Lexical context , Execution context and Closures – ChenLee Mar 21 '17 at 07:31
-
@ChenLee I have edited the answer a bit. The detailed definition of those concepts can be found all over the internet. The definitions are not clear always and it is easy to get confused between scope, lexical context, execution context etc. Only thing you can do is find more and learn more and that is how you become a world class developer. – Asish Bhattarai Mar 21 '17 at 07:56