Skip to content
Justice Tech School

let, const and var

Use const by default, let when the value changes and avoid var. let and const are block scoped. const prevents reassignment but objects stay changeable inside.

Example
const pi = 3.14;
let n = 1;
n = 2;
const o = { a: 1 };
o.a = 2;
console.log(pi, n, o);

Exercise

Never reassigned.

 rate = 0.1;

Quiz Test

Can you reassign a const?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.