[[Class]] and host objects

Douglas Crockford douglas at crockford.com
Tue Feb 10 12:26:29 PST 2009


 > Other than toString I  believe that the only directly
 > user observable use of [[Class]] is the new Array.isArray
 > function. The main use case for this was Doug's JSON
 > libraries that needed to determine which objects should be
 > output using array literal notation.  We now have enough
 > reflection support that he could write any sort of Array
 > litmus test that he thought was appropriate (for example,
 > length property value == largest numeric property name + 1).
 > Given that, maybe we don't really need Array.isArrary which
 > would probably simply the what does [[Class]]=="Array" mean
 > discussion.

There are lots of other uses for an isArray test. Since we can't fix typeof, 
Array.isArray is necessary.

The question is how does isArray work, does it look for [[Class]]=="Array" or 
does it do something more mysterious. If we can settle on what [[Class]] does, 
then that would seem better.



More information about the Es-discuss mailing list