Wooden Blocks with the text: Scope

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…

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

Share this post

Share on facebook
Share on google
Share on twitter
Share on linkedin
Share on pinterest
Share on print
Share on email
Skip to content