What is the reason why Javascript push objects by reference and not by value?
And why this behavior is only for objects and not also for built-in primitives types?
For example:
let x = {a: 10, b: 100 }
let ar = [];
ar.push(x);
x.a = 9;
console.log(ar[0].a); // This print 9, not 10
I think an answer to this question is useful to understand some deep functions about this language.
Thanks in advance.