Values, Types, and Expressions
Let and Const
Choose between a reassignable let and a fixed const.
Let and Const
let_const.js
let count = ;
const step = 2;
count = count + step;
const label = "count:" + count;
console.log("step=" + step);
console.log("count=" + count);
console.log("label=" + label);
let count = ;
const step = 2;
count = count + step;
const label = "count:" + count;
console.log("step=" + step);
console.log("count=" + count);
console.log("label=" + label);
let count = ;
const step = 2;
count = count + step;
const label = "count:" + count;
console.log("step=" + step);
console.log("count=" + count);
console.log("label=" + label);
let-const
Use `let` for a binding that will change and `const` for one that stays fixed. Reassigning a `let` updates the value the next expressions see.