Thaddee Tyl thaddee.tyl at
Sat Jun 6 13:32:46 UTC 2015

You suggest a list of types of fixed size. The lack of exposition of
user-definable value types is a problem you mention.

Having a better typeof is not as useful as having a better instanceof.

This would be more valuable:

isA(42, Number) === true  // Doesn't work with instanceof
isA([1,3], Array) === true  // Does work with instanceof
isA({one:1}, Object) === true  // The distinction between array and
object was always weird with typeof
class Thing {}
isA(new Thing, Thing) === true
class SubThing {}
isA(new SubThing, Thing) === true  // Detects subclassing / prototype
chain (which instanceof does not do)

JS needs Ruby's is_a?.

More information about the es-discuss mailing list