incubator-callback-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Patrick Mueller <>
Subject Re: `instanceof` considered harmful in cordova-js
Date Fri, 27 Apr 2012 19:01:24 GMT
On Fri, Apr 27, 2012 at 14:57, Filip Maj <> wrote:

> Here's the grep output from cordova-js, and I'll provide context for each
> little bit below the grep output. Five general cases. All but one
> instanceof check against a native type (and that one we can change away
> from testing against one of our defined types).

My vote is typeof for everything but Array and Date, and add some
handy-dandy util methods isArray() and isDate() to do the checking with the
toString hack().

Alternately, define a replacement for typeof called, say, isType(object,
string), and do all the relevant checks/hacks in there.  And throw an
exception if they pass a string we don't check for :-)

Patrick Mueller

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message