study

A diary of some sort. An interesting one.

Function Versus Block Scope


function somethingGood() { 
	
	// Some awesome code ...

}

are the most common units of scope variables and functions defined in these scopes are only available to scope and functions/scopes nested within. Functions/scopes outside the declared fucntion scope (e.g. the global scope) cannot “see” declared identifiers nested within.


{
	// .. This is a code block
}


{
	let a = 5;
	console.log(a); // returns 5
}

console.log(a); // throws up a reference Error

NOTE: Both the let and const keywords were introduced in ES6.