DEV Community

Kaziu
Kaziu

Posted on • Edited 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)