K
kj
My book (Flanagan's JavaScript: The Definitive Guide, 5th ed.)
implies on page 111 that the following two constructs are equivalent:
( x.constructor == Foo )
and
( x instanceof Foo )
The author states that the instanceof operator computes its result
by examining the value of its first argument's the constructor
property.
However, I've recently ran into a situation that contradicts this.
I've been trying to understand jQuery better, with the aid of
Firefox's Firebug debugger. At one breakpoint, there's one variable
(I'll call it x) for which
x instanceof jQuery
is true, but
x.constructor == jQuery
is false.
In fact, x.constructor is Object, but (Object instanceof jQuery)
is false.
Could anyone explain to me what's going on?
TIA!
Kynn
implies on page 111 that the following two constructs are equivalent:
( x.constructor == Foo )
and
( x instanceof Foo )
The author states that the instanceof operator computes its result
by examining the value of its first argument's the constructor
property.
However, I've recently ran into a situation that contradicts this.
I've been trying to understand jQuery better, with the aid of
Firefox's Firebug debugger. At one breakpoint, there's one variable
(I'll call it x) for which
x instanceof jQuery
is true, but
x.constructor == jQuery
is false.
In fact, x.constructor is Object, but (Object instanceof jQuery)
is false.
Could anyone explain to me what's going on?
TIA!
Kynn