I read that the variable is stored as a memory reference in js.
So, for a var a = 5cell with a value is 5assigned a.
I tried running this on node.js:
var a = 5;
var b = {
val: a
};
a = 6;
I expect that to b.valbe 6, but to be 5,
If I run:
var a = 5;
var b = {
val: a
};
var c = {
value: b
}
b.val = 6;
What c.value.valis 6.
If all objects are memory, why is there a difference in output?
source
share