Please enable JavaScript.
Coggle requires JavaScript to display documents.
Variable - Coggle Diagram
Variable
Scope
-
Function Declarations
When a Lexical Environment is created, a Function Declaration immediately becomes a ready-to-use function
-
Closure
-
in JavaScript, all functions are naturally closures (there is only one exception, to be covered in The "new Function" syntax).
-
Garbage collection
-
a Lexical Environment is removed from memory with all the variables after the function call finishes.
As the same for varible, variable like propery of Lexical Environment
Hoisting
only the declaration is hoisted, the assignment (if there is one), will stay where it is
-
Function declarations have the body hoisted while the function expressions only has the variable declaration hoisted.
var, let, const
let, const
let, const: sự bổ sung của ES6
-
const
like let, but we cant not redeclare anywhere.
-
var
-
-
Var have hoisting, and be initial is undefined