⏱ 0:06est. 2 min
Lesson 9- The Global Environment and The Global Object.
Notes
- Whenever the js code is executed, It runs inside an execution context(wrapper)
- Base execution context is the global execution context, Global execution context contains a global object and a special variable "this" (Window object) . These are created by javascript engine.
- It's inside the lexical environment.
- Open console and write "this" to verify window object. Even if the code is empty an execution context is created by javascript engine. Type "window" and it the same object as "this". This is the global object. It will not be available on node.js server, it will contain a different global object.
- There will be a global object if you are running javascript.
- Global Object(window) = this
- Global is not inside a function
- In javascript when you create var and function and you are not inside the function those var and functions are attached to the global object.
- At the base level when you are not inside the function there is a global object which a javascript engine creates for you as a part of that execution context.
- Environment outside the function is outer environment.