Variable Scope


Variable scope is a way to determining the lifespan of a variable in code.

Function Scope

Function scope is given to a JavaScript variable with the var keyword.

The above myVar variable cannot be accessed outside of the function myFunc().

Block Scope

As of EMCAScript 2015, JavaScript has block scoping capabilities. This is enabled with the introduction of the let keyword.

Posted: November 24th, 2015 at 7:57 am
Last Updated on: November 24th, 2015 at 8:00 am