"var" has a lot of problems, don't use it.
JS ⟩ variable ⟩ var ⟩ stop using var❗
var is a statement❗️(side effects)
global var / function is global object property❗️(side effect)
accessing var before declaration gets undefined❗️(unexpected result)
var has no block scope❗️ (unexpected result)
var in block can't shadow outer let❗️(unexpected result)
var can shadow parameter even in strict mode❗️(bad practice)
var redeclaration applied even in strict mode❗️(bad practice)
statement expected❗️❗
✅ always use strict mode
Statements and declarationsarrow-up-right ⟩ declaring variablesarrow-up-right ⟩ vararrow-up-right
Difference between statements and declarationsarrow-up-right ⭐️⭐️⭐️ ❗️❗️❗️
Last updated 3 years ago