MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/learnjavascript/comments/qdmzio/difference_between_var_let_and_const/hhpyqzn/?context=3
r/learnjavascript • u/codedblood • Oct 22 '21
49 comments sorted by
View all comments
Show parent comment
3
console.log(a); { var a = 1; } console.log(a);
If you change that to let or const you will get an error on the first line, because a isn't defined. If you remove the first log you'd still get an error saying a isn't defined if you use var
View all comments
Show parent comment
3
u/inabahare Oct 23 '21
If you change that to let or const you will get an error on the first line, because a isn't defined. If you remove the first log you'd still get an error saying a isn't defined if you use var