DEV Community

Shukroh
Shukroh

Posted on

What is the

DIFFERENCES BETWEEN VAR,LET AND CONST

Var: car can be used for function scoped variable that can be reassigned and updated with the same scope. Bar is hoisted that is, it can be accessed before it is declared
Let: let can be used for block scoped variables that can be reassigned but cannot be redeclared.
Const: const can be used for block scoped variables that cannot be reassigned.

WHY IS CONST USED THE MOST IN JAVASCRIPT
Const is used because whenever a variable is not reassigned in its scope. This makes the intent clear that a variables type can never change in the cas of primitive.

Top comments (0)