Re: Detecting the "type" of a DOM object

I think what I really want to write is:

   if (n.is(Node))
     ...

but I don't think that will fly.  It might be handy to be able to accept 
null and return true, too, although you could do that with the new ".?" 
operator.

Here are some method names I came up with (not all serious contenders):

   Node.describes(n)
   Node.defines(n)
   Node.names(n)
   Node.characterizes(n)
   Node.labels(n)
   Node.hasInstance(n)
   Node.has(n)
   Node.isValue(n)
   Node.isClassOf(n)
   Node.isInterfaceOf(n)
   Node.isImplementedBy(n)

I like Node.has for its succinctness.  hasInstance is all right too, but 
it has the downside of looking like [[HasInstance]] which doesn't handle 
multiple globals, the thing we're trying to avoid.

Received on Thursday, 21 June 2012 03:20:41 UTC