In JavaScript, each function gets its own scope. A function's scope
is a collection of variables, as well as the accessibility of these variables inside and outside of the function. Only code lexically residing within the function's block can access that function's scoped variables.

A variable name has to be unique within the same scope
. Additionally, a scope may also be nested inside another scope. If one scope is nested inside another, code inside the innermost scope can access variables from either scope.
In addition to letting you create declarations for variables at the function level, ES6
allows you declare variables that belong to individual blocks (pairs of { .. }), using the let
keyword.