Block Scope

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

More To Explore

Share This Post

small_c_popup.png

Need help?

Let's have a chat...


Login

Jump Back In!

Here at Webolution Designs, we love to learn. This includes sharing things we have learned with you. 

Register

Begin Your Learning Journey Today!

Come back inside to continue your learning journey.