r/learnjavascript • u/username95050 • Oct 23 '26
Block Scope
What is it? Don't understand what is inside or outside
12
Upvotes
r/learnjavascript • u/username95050 • Oct 23 '26
What is it? Don't understand what is inside or outside
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.
constandletare block scoped.varis not. Avar-declared variable remains accessible outside of the block's braces, inside the surrounding function braces.