let, const and var

Use const by default, let when the value changes, and avoid var.

JavaScript · let, const and varBeginner
const site = 'khurrambaig.com';   // cannot be re-assigned
let visits = 0;                    // can change
visits = visits + 1;

const user = { name: 'Ali' };
user.name = 'Ali Khan';            // allowed: the object changes, not the variable

if (true) {
  let inside = 'only here';        // block scope
}
// console.log(inside);            // ReferenceError
variablesletconstscope