random thoughts: it still looks weird to me to prefix undefined and null with "object", plus there is no undefined [[class]], neither Null one so despite the good intention, I believe null, NaN, and undefined, should return "[not an object]" as well as primitives should return "[primitive String]" as example, rather than "[object String]" since all primitives are metaphorically frozen without extensions allowed ... i.e.
var s = ""; s.whatever = 123; s.whatever; // undefined br On Sun, Jan 22, 2012 at 7:06 PM, Herby Vojčík <[email protected]> wrote: > David Bruant wrote: > >> Hi, >> >> SpiderMonkey implementation landed today. I was looking over the commit >> [1] and had a question. >> There is a test: >> >> assertEq(Object.prototype.**toString.call(new Map), "[object Map]"); >> >> I can't see anything about it neither in the latest spec draft nor in >> the wiki proposal. Is it how Object.prototype.toString should behave. I >> assume yes, but since there is no mention somewhere, it's probably worth >> discussing it. >> Likewise for Set. >> > > It is how Object.prototype.toString always (at least since ES5) behaved. > It was in the spec. The newest spec has: > > 15.2.4.2 Object.prototype.toString ( ) > When the toString method is called, the following steps are taken: > 1. If the this value is undefined, return "[object Undefined]". > 2. If the this value is null, return "[object Null]". > 3. Let O be the result of calling ToObject passing the this value as the > argument. > 4. If O has a [[NativeBrand]] internal property, let tag be the > corresponding value from the Table 23. > 5. Else, let tag be the string value "Object". > 6. Return the String value that is the result of concatenating the three > Strings "[object ", tag, and "]". > > And the Table23 that follows contains strings for native object types, > like Number, Math, Array, JSON etc. There is nothing for Map not Set, but > there is no Map or Set there in the first place (or I failed in searching > them). > > David >> >> [1] >> https://hg.mozilla.org/**mozilla-central/rev/**6a5e20a0f741<https://hg.mozilla.org/mozilla-central/rev/6a5e20a0f741> >> > > Herby > > ______________________________**_________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/**listinfo/es-discuss<https://mail.mozilla.org/listinfo/es-discuss> >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

