DEV Community

Discussion on: Pass By Reference Vs Pass By Value

 
ecyrbe profile image
ecyrbe

Oh, yeas, my bad.

Objects are references is the right explaination. At first you wrote : "Now objects are mutable and hold references to values" witch i interpreted as "Now Objects are mutable and properties hold references to values" which my example disproved.

But yes, One single Object is by itself stored as a reference to the actual object.
Proof

let test = { hello: "world" };
const test2 = test;
test.test = "test";
console.log(test2); // { hello: "world", test: "test" }
Enter fullscreen mode Exit fullscreen mode