r/learnjavascript • • Oct 23 '26

Block Scope

What is it? Don't understand what is inside or outside

12 Upvotes

8 comments sorted by

View all comments

5

u/iplayconnections Oct 23 '26

Scope is where you can access a variable. The block scope refers to the lines between opening and closing braces. If a variable is block scoped, it is accessible only within those braces where it is declared.

const and let are block scoped. var is not. A var-declared variable remains accessible outside of the block's braces, inside the surrounding function braces.