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
1
u/MissinqLink Oct 23 '26
if (Math.random() > 0.5) {
⠀const blockScopedVariable = 5;
⠀// this variable only exists inside this if statement
}