From: Dmitry A. Soshnikov on
On Nov 2, 7:42 pm, Lasse Reichstein Nielsen <lrn.unr...(a)gmail.com>
wrote:

> [...]
> The problem is what to call it.
> [...]

For do not mess with [by-value] passing (which could be treated as
huge objects structure copies and the changes withing the function are
independent from outside) and for do not mess with [by-reference]
passing (which is treated what direct reference is passed - changes
for either properties or object itself are visible for outside) - the
term [by-sharing] has been specially provided. The in general theory
it's called *[by-sharing]*. And local terminology in ES, Java, VB,
Python, Ruby - [by-value] or [by-reference] (e.g. in Ruby) - is the
local terminology for [by-sharing].

But, e.g. B.Eich also calls this [by-value]. So the most accurate
naming I think (when explaining this for someone) is: "in ES usually
used naming [by-value] - which means *special implementation-depended
by-value* - when passing *copy of the reference*, but also in general
theory this naming is known as [by-sharing]".

But actually passing the value to the function in this case is not
differers from simple assignment:

var a = {x: 10};
var b = a;

var refA = {base: Global, propertyName: "a"}; // address e.g. 0xFF
var refB = {base: Global, propertyName: "b"}; // address *copied* -
also 0xFF

a = {x: 20};
refA = {base: Global, propertyName: "a"}; // address changed e.g. 0xFA
(new)
refB = {base: Global, propertyName: "b"}; // address 0xFF (old)

So to understand this thing, even is not required to analyze
evaluation strategy.

Also the strict equals operator (===) can confuse if to not understand
how it works within.

function test(a) {
alert(a === b); // true
}
var b = {x: 10}; // address 0xFF
test(b); // *copy* of the address - 0xFF

It looks like (for those who think that formal parameter [a] is passed
by-reference) that [a] and [b] - is exactly the same object. But
indeed exactly the same - is only *value* - address. But [a] and [b]
of Reference type are different: one has base as an activation object,
the second - base as global:

aRef = {base: AO(test function context), propertyName: "a"};
bRef = {base: Global, propertyName: "b"};

In here we can see that this is different object but with the same
value - the same address. Just then when GetValue and [[Get]] is
called, the value is gotten like *(0xFF) - which points in both cases
for {x: 10}.

For that term [by-sharing] has been suggested. But, as creator of the
language calls this as [by-value] (implementation-depended by-value -
that's sure important) - better in explanation to mention two terms -
[special case of by-value] which is === [by-sharing].

/ds