Lecture 9 - Conceptual Aside Syntax Parsers, Execution Context and Lexical Environments
Lecture 9 - Conceptual Aside Syntax Parsers, Execution Context and Lexical Environments
The base executionncontext is the global execution context. Global means accesible
everywhere to everything in your code.
The Global execution context creates two things for you, automatically. 1. the
global object. 2. It creates a special variable called 'this'. The Javascript
engine is creating these two things for you whenver your code is run.
sample:
when a file is run, an execution context is created. and the exec context decided
the value of 'this'. that is why you can call this in the console.
interestingly, there is an avaible object called window, the same object as 'this'.
window is the global obejct inside browsers. In node js its a different object.
Nvertheless, there is a global objetc being created.
Now, window refers to the window currenlty open. the tab in the browser. Separate
tab means seaparate window global object.
**when one creates a global variable or function, these are attached to the global
object window. Therefore, when you run window in the console, you will see that the
global variables and functions that you created are actually inside the it.
ie. in console,
a == window.a
>outer environment - a link into the outer enviroment. if you're running code
inside the function, then the outer envroment is that which is ouside the fucntion.
When you are at the global execution context, then there is no outer environment.
that is null.
>summary
when you run a code, the execution context:
1. creates global object.
2. creates a special variable clled 'this', which, in browsers, is equal to window
in the global context.s
3. creates a link to the outer environent especially for non-globals - things
inside a function
4. runs your code
the execution context is the wrapper. and it did some additional stuff.