What is difference between var and let in JS? | Sololearn: Learn to code for FREE!


What is difference between var and let in JS?

which one most prefer to use 1. var 2. let

4/24/2021 2:25:11 AM


3 Answers

New Answer


finally i am getting that-- => variable name declared using var can be override but variable name declared using the let keyword doesn't allow us to override the variable name and it throws an error.. => let is introduce in ES6. => var is used in 90s and let is modern approach to declare variable in JS..


https://www.sololearn.com/discuss/763646/?ref=app https://www.sololearn.com/discuss/1089502/?ref=app https://www.sololearn.com/discuss/1491784/?ref=app https://www.sololearn.com/discuss/2535583/?ref=app https://www.sololearn.com/discuss/1911206/?ref=app https://www.sololearn.com/discuss/2679485/?ref=app


Var is a global variable, while let is a temporary variable within the code block.