> String.prototype is a String object (with string value ""),
> Function.prototype is a function, etc. If you try on ES5
> browsers you will get the same result. See the spec for the reason.
According to the most recent draft
> 21.1.2.3 String.prototype
>
> The initial value of String.prototype is the intrinsic object
> %StringPrototype% (21.1.3).
>
> This property has the attributes { [[Writable]]: false, [[Enumerable]]:
> false, [[Configurable]]: false }.
>
> 21.1.3 Properties of the String Prototype Object
> The String prototype object is itself an ordinary object. It is not a String
> instance and does not have a
> [[StringData]] internal slot.
“It is not a String instance and does not have a [[StringData]] internal slot.”
is essentially saying that it is n’either a string primitive value, or a String
wrapper object. Whether it reflects implementation reality or not is sort of
besides the point at this stage.
I believe making String non-exotic has been discussed, and if this has changed
from ES5, it could be related to that.
> On Feb 9, 2015, at 11:53 PM, Gary Guo <[email protected]> wrote:
>
> String.prototype is a String object (with string value ""),
> Function.prototype is a function, etc. If you try on ES5 browsers you will
> get the same result. See the spec for the reason.
>
> Subject: Re: @@toStringTag spoofing for null and undefined
> From: [email protected]
> Date: Mon, 9 Feb 2015 16:43:23 +0100
> CC: [email protected]; [email protected]
> To: [email protected]
>
>
> Le 9 févr. 2015 à 16:15, Gary Guo <[email protected]> a écrit :
>
> I propose addition of String.prototype[@@toStringTag] as well as abridgement
> of Object.prototype.toString.
>
> The issue with that approach, is that `O.p.toString.call(String.prototype)`
> will return "[object String]", but, for ES6, `String.prototype` is not a
> String object, leading to a false positive that could break legacy code.
> (Don't know whether it is a problem in practice.)
>
> ―Claude
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss