redeclare | reassign | scope | initialize | |
---|---|---|---|---|
let | ⛔ | ✅ | 🗳 block | ⛔ |
const | ⛔ | ⛔ | 🗳 block | ⛔ |
var | ✅ | ✅ | function | "undefined" |
💎 const
the word const
comes from constant, so it shouldn't change at all.
- redeclare -> NO❗
- reassign -> NO❗
- scope -> block! We protect const in block !!
- initialize -> of course NO❗
💎 let
let
is actually almost const
except one thing
- reassign -> OK ✅
💎 var
var
is so much freedom man, it's not recommended now
▼ and difference of hoisting, I've wrote about it in other article
Top comments (0)