var
🚧 under construction
Last updated
Was this helpful?
🚧 under construction
Last updated
Was this helpful?
⟩ ⟩ var
Stop using var ( see )
( var is a statement, not a declaration)
declares a variable in function scope / global scope ( and does a lot of side effects).
var
is a reserved word
is a statement, not a declaration( 👉 var is a statement❗️)
doesn't have block scope. ( 👉 var has no block scope❗️)
compare: function declaration
in global scope,
var / function are implemented as global object property
these properties cannot be deleted with delete
Variable Statement
var statement declares variables that are scoped to the 's VariableEnvironment.
var variables are created when their containing is instantiated and are initialized to undefined when created.
Within the scope of any VariableEnvironment a common may appear in more than one but those declarations collectively define only one variable.
A variable defined by a with an is assigned the value of its 's when the is executed, not when the variable is created.
📘 JS spec ⟩
itHome ⟩ ⟩
⟩ ⟩