3 ms·
> The object is still passed by value, however the object itself contains references, which may be mutated. This would imply that: var v = 1; (function (
by mnarayan01 9y ago
> The object is still passed by value, however the object itself contains references, which may be mutated.
This would imply that:
var v = 1;
(function (o) {
o.a = 2;
}({ a: v });
console.log(v); // => 2
The whole "objects are pass-reference-by-value" is obviously annoying and confusing, but we're kind of stuck with it.
- shkkmo 9y agoApparently there is another term (which I hadn't heard) which is: call-by-sharing https://en.m.wikipedia.org/wiki/Evaluation_strategy#Call_by_sharing https://en.m.wikipedia.org/wiki/Evaluation_strategy#Call_by_...