Var: Var is a function-scoped and can be redeclared and reassigned.
var a=10;
a=20;
console.log(b);
Output:
20
Let: Var is a block-scoped and can be reassigned but not redeclared.It's used for variables that change.
let a=30;
a=10;
console.log(b);
Output:
10
Const:Const is a block-scpoed cannot be reassigned or redeclared.It's used for fixed values.
const a=110;
a=80;
console.log(b);
Output:
110
Top comments (0)