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

Re: Detecting the "type" of a DOM object

From: Bjoern Hoehrmann <derhoermi@gmx.net>
Date: Thu, 21 Jun 2012 06:03:03 +0200
To: Boris Zbarsky <bzbarsky@MIT.EDU>
Cc: "public-script-coord@w3.org" <public-script-coord@w3.org>
Message-ID: <8o65u79tkqam5ik9to0ndtvbvoqfdtc2j1@hive.bjoern.hoehrmann.de>
* 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?
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 
Received on Thursday, 21 June 2012 04:03:33 UTC

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