Mutable Object References
Mutable values are values that can be changed without an entirely new value. In JavaScript objects and arrays are mutable by default. As already said in a previous post about Immutable Primitive Values, there is a fundamental difference in JavaScript...
kcoderk.hashnode.dev1 min read
Keep in mind, particularly with objects and arrays you can achieve immutability with object and array spread operators respectively as follows :
With objects:
let a = {x: 1} let b = {...a} b.x = 2; console.log(a.x) // still x === 1With arrays :
let a = ["one"] let b = [...a] b[0] = "two"; console.log(a.x) // still outputs as "one"Cheers !