RobG wrote:
Quote:
On Dec 9, 1:06 am, David Mark wrote:
Quote:
>On Dec 8, 9:15 am, Thomas 'PointedEars' Lahn wrote:
[...]
Quote:
Quote:
>>It is therefore inappropriate to speak of objects as
>>instances of their constructors.
>>
>Thanks for that.
>
Maybe the instanceof operator should be "constructedby"? :-)
The - instanceof - operator makes an assertion about the runtime
relationship between the objects on an object's prototype chain and the
object/value referred to by the - prototype - property of a function at
the moment of the operation. Because the - prototype - properties of
functions can be assigned values at any time the results of -
instanceof - do not necessarily represent anything beyond the outcome of
the pertinent algorithms.
As usual, if the 'Class' concept has been employed in javascript code
design, not violated at runtime, and no attempt has been made to extend
that concept across possible multiple frames (so there is only a single
instance of each 'constructor') then javascript's - instanceof - can be
employed as if it was broadly analogous to Java's - instanceof -.
Unfortunately the coincidence of names tends to give people familiar
with Java the false impression that the two operators are more related
than they actually are (and then they whinge when they find out that the
relationship in javascript is much more specific and concrete than the
conceptual relationship that is implied in Java).
Richard.