Re:Deep-copying in JavaScript
by zamalek on Thursday January 25, 2018 @04:13PM
(#16234725)
Not according to the comment that I am replying to:
> A reference is basically a pointer that the language prevents you from doing pointer arithmetic on, and in many languages such as PHP, is simply automatically dereferenced for you.
Also, the implicit is usually pass-by-value.
function foo(a) { a++; }
function bar(ref a) { a++; }
b = 1;
foo(b); // Pass by value, implicit.
assert(b == 1);
bar(ref b); // Pass by reference.
assert(b == 2);
Heap vs. stack values are not the same thing as pass-by-reference and pass-by-value.
> A reference is basically a pointer that the language prevents you from doing pointer arithmetic on, and in many languages such as PHP, is simply automatically dereferenced for you.
Also, the implicit is usually pass-by-value.
Heap vs. stack values are not the same thing as pass-by-reference and pass-by-value.