0
What are the advantages and disadvantages of using let vs var when declaring variables in JavaScript?
answer me pleaseđ
3 Answers
+ 3
ă”ăăłă”ăĄăă
Consider using search bar before posting a question:
https://www.sololearn.com/discuss/840637/?ref=app
https://www.sololearn.com/discuss/3332369/?ref=app
https://www.sololearn.com/discuss/3279959/?ref=app
https://www.sololearn.com/discuss/763646/?ref=app
https://www.sololearn.com/discuss/1518384/?ref=app
https://www.sololearn.com/discuss/3041287/?ref=app
https://www.sololearn.com/discuss/2535583/?ref=app
https://www.sololearn.com/discuss/2764515/?ref=app
https://www.sololearn.com/discuss/1491784/?ref=app
https://www.sololearn.com/discuss/1089502/?ref=app
https://www.sololearn.com/discuss/2930947/?ref=app
0
Well, let makes a variable only able to be accessed in the block it's in, while var allows it to be used in the entire function (for ex script tags) that they are declared in
0
while using let might feel more limiting than var, it's the safer option.
Avoid var. it's problematic and introduces unexpected bugs because of it's non-standard behavior.