DEV Community

Discussion on: Similar yet different. So confusing

 
stereobooster profile image
stereobooster

Referential transparency - means you can't reassign variable.

const a = { x:  1 };
const b = a;
a.x = 2;
a === b; //true, because it is the same reference

Immutability - means you can't mutate object.

let a = Object.freeze({x : 1})
a.x = 2;
a.x === 1; // true, because a is immutable