J
John G Harris
The words that actually say what exactly? There are no words in the
spec that say "can ... conclude", the ability to do that as a result
of the observation is evidently a fact (as at least one person has
done so).
Yes, I didn't say it very clearly. I want to know which words in ECMA
262 say that you can get at the insides of the same object via two
different variables. I've finally managed to plough through the many
sections of the standard needed to find the answer.
Suppose you execute these two statements :
b = new Object();
c = b;
and follow the formal ES3 definitions of what will happen. After tracing
through all the gets, puts, returns, etc. you will find that the 'value'
of b *is* the newly created object, and the 'value' of c is also that
same object. Thus any change to the insides of the new object made via b
is also visible via c.
Obviously, the meaning of 'value' in ECMAScript is somewhat different to
its meaning in other languages.
If 'value' seems confusing then we can turn to the informal ES3 Overview
section where properties are said to be containers. Each property, and
so each variable, is said to contain either a primitive value or an
object. Thus both b and c contain the same newly created object in the
same way that both New York and North America contain Wall Street.
Unlike real geography, an object can indirectly contain itself, making
life difficult for the garbage collector.
If you ask whether function arguments are passed by this or by that or
by something else in ECMAScript the only correct answer is that all
arguments are passed by containment. Any disagreement can only be about
which feature of which other language it most closely resembles.
The ES5 standard adds much complication to the formal definitions but
appears to make no essential difference to these conclusions.
John