DEV Community

Kaziu
Kaziu

Posted on • Updated on

๐Ÿ‘€ var, let, const in javascript . just 30sec

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)