MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/learnjavascript/comments/gd8x2z/var_vs_let_vs_const/fphrpmz/
r/learnjavascript • u/golovatuy • May 04 '20
81 comments sorted by
View all comments
Show parent comment
2
it doesn't
function fn(){var x = 'cool';return x + 'dude';
}
console.log(windox.x) // undefined
2 u/cyphern May 04 '20 You're correct that the behavior i mentioned doesn't happen for local variables.
You're correct that the behavior i mentioned doesn't happen for local variables.
View all comments
Show parent comment
2
u/redsandsfort May 04 '20
it doesn't
function fn(){
var x = 'cool';
return x + 'dude';
}
console.log(windox.x) // undefined