Re: Detecting the "type" of a DOM object

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.

-Boris

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