Different types of Scopes

Global Scope

Any variable that's not inside a function or block (curly brace).

Local Scope

Any variable declared inside a function

Block Scope

This refers to let and const which unlike var are only accessible within the scope that they were defined.

Lexical Scope

Lexical Scope (also known as Static Scope) literally means that scope is determined at the lexing time (generally referred to as compiling) rather than at runtime.

Dynamic Scope

Scope determined by the this keyword during function invocation.

Resources

https://blog.bitsrc.io/understanding-scope-and-scope-chain-in-javascript-f6637978cf53

Last updated