function – What is the scope of variables in JavaScript?

TLDR JavaScript has lexical (also called static) scoping and closures. This means you can tell the scope of an identifier by looking at the source code. The four scopes are: Global – visible by everything Function – visible within a function (and its sub-functions and blocks) Block – visible within a block (and its sub-blocks) … Read more