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

1

u/MissinqLink Oct 23 '26

if (Math.random() > 0.5) {

⠀const blockScopedVariable = 5;

⠀// this variable only exists inside this if statement

}