let a = {"foo": 99};
let b = a;
// console.log(b) {"foo": 99}
a.foo = 33;
// console.log(b) {"foo": 33}
I understand in the scenario above that if I use objects, the variable referencing the original object will reflect the value of the original object.
But if I do this with arrays:
let a = [1,2,3];
let b = a;
a = [99,99,99];
// console.log(b) [1,2,3];
variable b still references the original value of a even after a changed so then what would the person of creating a copy via slice() serve?