Understanding Scopes

In this lesson, we’ll see what scopes in JavaScript are.

JavaScript has an important concept, execution context, which should be understood by all developers.


The context of a function or variable defines how the function or variable behaves, as well as other data it has access to.


Behind the scenes, the JavaScript engine associates a variable object to each execution context, and all functions and variables defined in the context exist in this variable object.

📜NOTE: The variable object is not accessible by code.

When a function is invoked, a new context is created for the function and it is pushed onto a context stack. After the function has been executed, this stack is popped, and the control is returned to the previously executed context.

There is a global execution context, it is the outermost one, the first to be put onto the context stack. In web browsers, the global context belongs to the window object which represents an instance of the ...

Access this course and 1400+ top-rated courses and projects.