Var, Let, Const difference
- Var
- Duplicate declaration possible Scope: global, function
1
2
var first = 10;
var fitst = 20;
- Let
- Duplicate declaration
NOTpossible Scope: global, function
1
2
let second = 10;
let second = 20; # error !
- Const
- Duplicate declaration
NOTpossible- Initialize at the time of declaration
Final
| Section | Var | Let | Const |
|---|---|---|---|
| Re-declaration | O | X | X |
| Update | X | O | X |
| Scope | Global | Block | Block |