You can declare variables using var, let, or const:
let age;
const pi = 3.14;
var name = "Alice";var: function-scoped, can be redeclaredlet: block-scoped, preferred for mutable valuesconst: block-scoped, used for immutable valuesvar x = 10;
let y = 20;
const z = 30;You can assign values during or after declaration:
let language = "JavaScript";
let score;
score = 100;$, or _$, _score and Score are different)let x = 5;
x = 10; // OK
const y = 15;
y = 20; // ❌ Error: Assignment to constant variableconst by default for safetylet when you need to reassign valuesvar in modern codeAsk the AI if you need help understanding or want to dive deeper in any topic