Questions on Map and Set based on SpiderMonkey implementation

Andrea Giammarchi 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

br

On Sun, Jan 22, 2012 at 7:06 PM, Herby Vojčík <herby at mailbox.sk> 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
> es-discuss at mozilla.org
> https://mail.mozilla.org/**listinfo/es-discuss<https://mail.mozilla.org/listinfo/es-discuss>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120123/5a593999/attachment.html>


More information about the es-discuss mailing list