MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/learnjavascript/comments/jic377/javascript_string/ga7fisf/?context=3
r/learnjavascript • u/tutorialstonight • Oct 26 '20
javascript string 🔥
https://www.tutorialstonight.com/js/js-string.php
31 comments sorted by
View all comments
47
You should really avoid using 'var' to declare your variables.
21 u/I-DONT-WANT-GOLD Oct 26 '20 Why? 13 u/scandii Oct 26 '20 edited Oct 27 '20 downvoted for asking a question... this sub.let has a block scope, i.e lives ans dies in the scope it is declared, whereas var is global or if in a function has a function scope and can be used anywhere.this can lead to some nasty side effects and is as such not recommended. 4 u/awkreddit Oct 26 '20 Var is not global at all, var is scoped to the function, let is scoped to the block.
21
Why?
13 u/scandii Oct 26 '20 edited Oct 27 '20 downvoted for asking a question... this sub.let has a block scope, i.e lives ans dies in the scope it is declared, whereas var is global or if in a function has a function scope and can be used anywhere.this can lead to some nasty side effects and is as such not recommended. 4 u/awkreddit Oct 26 '20 Var is not global at all, var is scoped to the function, let is scoped to the block.
13
downvoted for asking a question... this sub.
let has a block scope, i.e lives ans dies in the scope it is declared, whereas var is global or if in a function has a function scope and can be used anywhere.
this can lead to some nasty side effects and is as such not recommended.
4 u/awkreddit Oct 26 '20 Var is not global at all, var is scoped to the function, let is scoped to the block.
4
Var is not global at all, var is scoped to the function, let is scoped to the block.
47
u/MrMimmet Oct 26 '20
You should really avoid using 'var' to declare your variables.