SyntaxStudy
Sign Up
JavaScript Beginner 1 min read

var, let & const

var, let & const

varletconst
ScopeFunctionBlockBlock
Re-assignYesYesNo

Best Practice

Use const by default. Use let when you need to reassign. Avoid var.

Example
const PI = 3.14;    // won't change
let count = 0;      // will change
count++;
const user = {};
user.name = 'Alice'; // OK — mutating object