I think the terms and most of the examples are a bit overwhelming,
The main issue i had personally with the difference is understanding what a "Block" is.
At some point i realized, a block would be any curly brackets except for IF
statement.
an opening bracket {
of a function or loop will define a new block, anything defined with let
within it, will not be available after the closing bracket }
of the same thing (function or loop);
With that in mind, it was easier to understand:
let msg = "Hello World";_x000D_
_x000D_
function doWork() { // msg will be available since it was defined above this opening bracket!_x000D_
let friends = 0;_x000D_
console.log(msg);_x000D_
_x000D_
// with VAR though:_x000D_
for (var iCount2 = 0; iCount2 < 5; iCount2++) {} // iCount2 will be available after this closing bracket!_x000D_
console.log(iCount2);_x000D_
_x000D_
for (let iCount1 = 0; iCount1 < 5; iCount1++) {} // iCount1 will not be available behind this closing bracket, it will return undefined_x000D_
console.log(iCount1);_x000D_
_x000D_
} // friends will no be available after this closing bracket!_x000D_
doWork();_x000D_
console.log(friends);
_x000D_