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)

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay