W3C home > Mailing lists > Public > public-script-coord@w3.org > April to June 2012

Re: Detecting the "type" of a DOM object

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Thu, 21 Jun 2012 01:31:59 -0400
Message-ID: <4FE2B1CF.9050508@mit.edu>
To: Bjoern Hoehrmann <derhoermi@gmx.net>
CC: "public-script-coord@w3.org" <public-script-coord@w3.org>
On 6/21/12 12:03 AM, Bjoern Hoehrmann wrote:
> * Boris Zbarsky wrote:
>> There's a common problem where someone has an object and they would like
>> to tell whether it's a Node (or an Array or a Date or whatever).  Right
>> now, the way to do that is to use instanceof.... but with a huge caveat:
>> you have to pull the Node or Array or whatnot off the right global object.
>> I was wondering whether it would make sense to expose, on DOM
>> constructor objects, a method that lets you test whether some other
>> object is of that type.
> Would you prefer such a method over having a proper `instanceof`-like
> operator on the language level that does not have the problem you cite?

No.  If we can come up with a language-level solution to this, that 
would be vastly preferable.  In my opinion.

Received on Thursday, 21 June 2012 05:32:28 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:06 UTC