John said:
It's not me that's confused. You attached the function to Object, a
constructor. That is what I was commenting on.
In order to save yourself from further embarassment, you really want to have
at least a look at the ECMAScript Language Specification, Edition 5 Final,
before further commenting on the programming that is on-topic here.
<snip>
There is no conflict. Which values are to be compared is resolved by the
function's specification. You do have one, don't you? From the displayed
code it appears to be obj1 and obj2; the this value is not used.
I was talking about the other way to implement this,
Object.prototype.equals(), in that paragraph, as can be seen further above.
Assuming it would be implemented that way,
Object.prototype.equals = function(obj1, obj2) {
…
};
then Object instances (and all objects that inherit from [the object
referred to by] Object.prototype through their prototype chain) would
inherit that method (which is part of why that is not a good idea at the
moment). Then it would be possible to call
({}).equals(foo, bar);
and one would need to decide in one's implementation what value acts as the
`this' value in the equals() code, if any: either that of `foo', or that of
`bar'. (My recommendation stands that it should be that of `bar'.)
Such considerations do not have to be made if you have a "static" method
that is not inherited by other objects implicitly, as in the first approach.
Those methods are not supposed to be transferred to other objects.
PointedEars