couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Davis <>
Subject Re: Doug Crockford's typeOf vs usual js typeof
Date Wed, 26 Aug 2009 15:36:17 GMT
On Wed, Aug 26, 2009 at 11:31 AM, Jesse Hallett<> wrote:
> A simpler test is:
>    [1,2,3] instanceof Array
> Though as Crockford points out that test may not be as reliable as `typeOf`
> in some cases.  The scenario in which Crockford says `typeOf` will work
> better is when to object being tested was created in a different window or
> frame.  That case may not apply to CouchDB views.

I'm not familiar with the Remedial book,  but the fact that it was
worried about different windows suggest that maybe it was because the
object was created in a different context, which could mean that
instanceof would fail because it would be two different Array classes
being checked. If that really is the case then you shouldn't ever have
the same problem in CouchDB JS.

Paul Davis

View raw message