Variable scope
A variable can either be in the global scope, the function scope, or the block scope.
Functions and branching statements use curly braces ({ and }) to indicate a sequence of instructions.
- Function scope - the variable is accessible anywhere in a function (behavior for
var) - Block scope - the variable is accessible in the nearest enclosing braces (behavior of
letandconst) - Global scope - a variable that is declared outside any function or block