This is kinda a meta-JS-question, but I was reading through this section in the "You Don't Know JS" book, and I am wondering how the JS engine finds the parent scope. Does the engine itself know where to find the next highest scope (if it's not already in global
) or does the current scope tell the engine what its parent scope is?
Asked
Active
Viewed 38 times
0

redOctober13
- 3,662
- 6
- 34
- 61
-
This might help: http://stackoverflow.com/questions/111102/how-do-javascript-closures-work – jds Sep 21 '15 at 20:40
-
See [*http://jibbering.com/faq/notes/closures/*](http://jibbering.com/faq/notes/closures/), though the terms used are based on ECMA-262 ed 3, they still apply to ECMAScript 2015. – RobG Sep 21 '15 at 21:07
-
Thanks for the links. I get closures, but this is more of a question about when the JS code is compiled and the engine is looking up variable and function references. Does it traverse the scope on its own? In other words, is the engine (e.g. V8) aware of all the different scopes, or does it get parent scope information from the current scope it's investigating? – redOctober13 Sep 23 '15 at 15:24