Account Options

  1. Sign in
Google Groups Home
« Groups Home
Message from discussion "x.constructor == Foo" vs "x instanceof Foo"
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
kj  
View profile  
 More options Jan 27 2008, 4:47 pm
Newsgroups: comp.lang.javascript
From: kj <so...@987jk.com.invalid>
Date: Sun, 27 Jan 2008 21:47:54 +0000 (UTC)
Local: Sun, Jan 27 2008 4:47 pm
Subject: "x.constructor == Foo" vs "x instanceof Foo"

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

--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.