JavaScript Scope and Closures

Scopes and closures are important in JavaScript. But, they were confusing for me when I first started. Here’s an explanation of scopes and closures to help you understand what they are.

Let’s start with scopes.
A scope in JavaScript defines what variables you have access to. There are two kinds of scope – global scope and local scope.
Global scope
If a variable is declared outside all functions or curly braces ({}), it is said to be …

JavaScript Scope and Closures is a post from CSS-Tricks