menu
techminis

A naukri.com initiative

google-web-stories
Home

>

Programming News

>

Js intervi...
source image

Dev

2w

read

271

img
dot

Image Credit: Dev

Js interview #1 : var, let, and const in JavaScript – What's the Difference?

  • JavaScript variables can be declared using var, let, or const, with differences in scope, hoisting, reassignment, and more.
  • 1. Scope: var is function-scoped, while let and const are block-scoped.
  • 2. Hoisting: var is hoisted and initialized, while let and const are hoisted but not initialized.
  • 3. Redeclaration & Reassignment: var allows both redeclaration and reassignment, let allows reassignment but not redeclaration, and const allows neither.
  • 4. Temporal Dead Zone (TDZ): Variables declared with let and const have a Temporal Dead Zone where they cannot be accessed before declaration.

Read Full Article

like

16 Likes

For uninterrupted reading, download the app