Perils of Mutability

Learn why the immutability concept was introduced in JavaScript.

let does not permit the redefinition of variables, but it allows changing the value held in the variable.

Mutable data example in JavaScript

Without executing it, look at the following code to determine what the output will be.

Press + to interact
'use strict';
let factor = 2;
let product = function(number) {
return number * factor;
};
factor = 0;
console.log(product(4));

Show the code to your colleagues nearby or far away. What good is technology if you can’t use it to bother someone with a coding problem? Ask them to ...