3 ms·
The confusion comes up when you do a _shallow_ copy: Some modifications will modify the original variable, and other modifications won't. Pass-reference-by-val
by Zarel 9y ago
The confusion comes up when you do a _shallow_ copy: Some modifications will modify the original variable, and other modifications won't.
Pass-reference-by-value is just a special case of a shallow copy.
let a = [1, 2, 3];
let b = a;
b[1] = 5; // will modify a
b = [1, 6, 3]; // will not modify a
In languages like C++, there's a way to make it so that last line _would_ modify a, which is why there's a need to use different words for the different phenomenon.