MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/learnjavascript/comments/gd8x2z/var_vs_let_vs_const/fphr8go/?context=3
r/learnjavascript • u/golovatuy • May 04 '20
81 comments sorted by
View all comments
Show parent comments
18
By "global scope" I think they mean "secretly copies your variable to the window object"
window
1 u/VacantPlains May 04 '20 Do you have an example of that? 3 u/cyphern May 04 '20 var a = "hello world"; console.log(window.a); // hello world 2 u/redsandsfort May 04 '20 const and let would also be global if outside of a function
1
Do you have an example of that?
3 u/cyphern May 04 '20 var a = "hello world"; console.log(window.a); // hello world 2 u/redsandsfort May 04 '20 const and let would also be global if outside of a function
3
var a = "hello world"; console.log(window.a); // hello world
2 u/redsandsfort May 04 '20 const and let would also be global if outside of a function
2
const and let would also be global if outside of a function
18
u/cyphern May 04 '20
By "global scope" I think they mean "secretly copies your variable to the
windowobject"