Questions on Map and Set based on SpiderMonkey implementation
andrea.giammarchi at gmail.com
Sun Jan 22 15:12:08 PST 2012
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
On Sun, Jan 22, 2012 at 7:06 PM, Herby Vojčík <herby at mailbox.sk> wrote:
> David Bruant wrote:
>> SpiderMonkey implementation landed today. I was looking over the commit
>>  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:
> 18.104.22.168 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
> 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
>>  https://hg.mozilla.org/**mozilla-central/rev/**6a5e20a0f741<https://hg.mozilla.org/mozilla-central/rev/6a5e20a0f741>
> es-discuss mailing list
> es-discuss at mozilla.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss