FWIW, ECMA-262 says: 15.2.4.2 Object.prototype.toString ( ) When the toString method is called, the following steps are taken: 1. Get the [[Class]] property of this object. 2. Compute a string value by concatenating the three strings "[object ", Result(1), and "]". 3. Return Result(2).
and.. 15.4.2.1 new Array ( [ item0 [ , item1 [ , … ] ] ] ) This description applies if and only if the Array constructor is given no arguments or at least two arguments. The [[Prototype]] property of the newly constructed object is set to the original Array prototype object, the one that is the initial value of Array.prototype (15.4.3.1). The [[Class]] property of the newly constructed object is set to "Array". - James On Thu, Mar 12, 2009 at 11:01 AM, John Tamplin <[email protected]> wrote: > On Thu, Mar 12, 2009 at 10:47 AM, Joel Webber <[email protected]> wrote: > >> Wow. Just wow. It never ceases to amaze me how esoteric simple type >> introspection can be in Javascript :) >> Yes, we should patch this in, and perhaps as a side-effect encode this >> (and other?) Javascript type tests into the core module somewhere. I'll >> create an issue so we don't lose track, and take a stab at a patch >> momentarily. >> > > I worry about relying on the toString output to tell what type it is -- > what if a future browser/JS engine changes it slightly? Can we at least add > a test to verify this so at least we will know if it blows up? > > -- > John A. Tamplin > Software Engineer (GWT), Google > > > > > --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/Google-Web-Toolkit-Contributors -~----------~----~----~----~------~----~------~--~---
