Skip to main content

Command Palette

Search for a command to run...

Difference Between Var, Let, and Const

Published
1 min read
Difference Between Var, Let, and Const
S

Run | Jump | Roar The World

Var: Function Scope, allowing access throughout the entire function, hoisted to the top of its block scope, but not block scoped. Can be redeclared or reassigned.

Let: Block scope ( for, while, if)- Hoisted to the top of its block but not initialized, resulting in a temporal dead zone if accessed before declaration. Let can't be redefined but can change the value at the same scope

Const: Block Scope - Hoisted and not initialized, leading to a temporal dead zone if accessed before the declaration. Const can't redefined or redeclared.

Difference Between Var, Let, and Const