Into Javascript

var nameTag = 69;

typeof nameTag; // > Outputs "number"
var a = 1,
  b = 2,
  c = 3;

if (b > a) {
  let c = 5;
  console.log(c);
} //> outputs 5

console.log(c); //> outputs 3
(function someFunction() {
  // ... some code ...
})();

The important thing to note there is the presence of parenthesis wrapping the function statement another another set of parenthesis immediately after the statement.
The function above operates identical to:

function someFunction() {
  // ... some code ...
}

someFunction();

Functions declared following the above format are referred to as Immediately Invoked Function Expressions (IIFEs).


All I can grasp from the concept of Closure (for now) is the fact that it’s mostly about rememberance. Let me explain as best I can from my very limited exposure to closures…

Generally I know that from the concept of Lexical Scopes, when a variable is created within a function using the var keyword, that variable is only valid, it only “exists”, within that function and all other child functions of it.

Since child functions of the parent function housing the variable in question can access the variable, they are said to have closure over the variable.