JavaScript also uses block scope. When we say block, we are referring to a code block. A code block is contained within curly braces. Information is encapsulated to the curly braces within the block of code. Here is an example…
If( 1 === 1) {
let name = ‘Bongo’;
}
console.log(name);
Since the variable name is within the curly braces, or block of code, it is not available outside of those curly braces. The log statement would return undefined.
Happy Coding!
Clay Hess