MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/learnjavascript/comments/jic377/javascript_string/ga8gwxr/?context=9999
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. 6 u/I-DONT-WANT-GOLD Oct 26 '20 Yeah, sorry if it was such a dumb question, but I was genuinely asking. Thank you! 15 u/scandii Oct 26 '20 there are no dumb questions only stupid answers. 1 u/beelzebut Oct 27 '20 You actually gave him a bad answer tho
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. 6 u/I-DONT-WANT-GOLD Oct 26 '20 Yeah, sorry if it was such a dumb question, but I was genuinely asking. Thank you! 15 u/scandii Oct 26 '20 there are no dumb questions only stupid answers. 1 u/beelzebut Oct 27 '20 You actually gave him a bad answer tho
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.
6 u/I-DONT-WANT-GOLD Oct 26 '20 Yeah, sorry if it was such a dumb question, but I was genuinely asking. Thank you! 15 u/scandii Oct 26 '20 there are no dumb questions only stupid answers. 1 u/beelzebut Oct 27 '20 You actually gave him a bad answer tho
6
Yeah, sorry if it was such a dumb question, but I was genuinely asking. Thank you!
15 u/scandii Oct 26 '20 there are no dumb questions only stupid answers. 1 u/beelzebut Oct 27 '20 You actually gave him a bad answer tho
15
there are no dumb questions only stupid answers.
1 u/beelzebut Oct 27 '20 You actually gave him a bad answer tho
1
You actually gave him a bad answer tho
47
u/MrMimmet Oct 26 '20
You should really avoid using 'var' to declare your variables.