Re: Fixing instanceof / typeof

2012-10-16 Thread Irakli Gozalishvili
Most recently I needed that to do polymorphic function dispatch on input argument type. More specifics can be found here: https://github.com/Gozala/method/blob/master/core.js#L121-127 This case may be quite exotic, but I remember running into this quite a lot, can't use cases unfortunately. BT

Re: Fixing instanceof / typeof

2012-10-15 Thread Brendan Eich
Just curious: why did you need a nominal type test, rather than a "duck type" test? /be Irakli Gozalishvili wrote: Hi, Today I had to deal with a value type detection in JS and that reminded me of all the pain associated with it, especially when dealing with values that may have come across

Re: Fixing instanceof / typeof

2012-10-15 Thread Andrea Giammarchi
you have a getClass mechanism but no getImplementedInterfaces one ... also never thought about xpcomponents but at least I would speed up that function via {}.toString.call rather than that double lookup per each call :-) However, xpconnect is a very specific use case so you might decide to R

Fixing instanceof / typeof

2012-10-15 Thread Irakli Gozalishvili
Hi, Today I had to deal with a value type detection in JS and that reminded me of all the pain associated with it, especially when dealing with values that may have come across the diff compartment / frame / context. `instanceof` is useless when dealing with objects from diff contexts, `typeof`