Chapter 210m
let & const
Declare variables the modern way.
This content is not yet available in ne. Showing English version.
View in English →let & const
Use let for variables that change, const for values that don't.
js
let score = 0;
score = 10; // OK
const pi = 3.14;
pi = 3; // ❌ TypeErrorOld var
Avoid var — it has function scope and is hoisted, which causes bugs. Always prefer let / const.
Example
javascript// let and const
let score = 0;
score = 10;
console.log("Score:", score);
const playerName = "Aarav";
console.log("Player:", playerName);