block scoped in js
The area of the code which is within {curley brackets} is called a block if (true) { ///block start var x = 2; let y = 2; } // block end
Here is what the above code is Doing:
1. The if statement is checking if the condition is true.
2. If the condition is true, then the code within the block is executed.
3. The code within the block is executed.
4. The code within the block is finished executing.
5. The block is finished executing.
6. The if statement is finished executing.