Le 02/11/2013 01:08, Brandon Benvie a écrit :
On 11/1/2013 4:59 PM, Brandon Benvie wrote:
On 11/1/2013 4:31 PM, Brandon Benvie wrote:
In the spec for Object.prototype.toString:
'If tag is any of "Arguments", "Array", "Boolean", "Date", "Error",
"Function", "Number", "RegExp", or "String" and SameValue(tag,
builtinTag) is false, then let tag be the string value "~"
concatenated with the current value of tag.'
An interesting consequence of this is that a Proxy for any of these
will default to being "~" + target class. So
`Object.prototype.toString.call(new Proxy([], {}))` is "[object
~Array]". But it seems the shipped has already sailed on Proxies
being conspicuously not interchangeable with their targets in many
cases...
Actually that's incorrect. Proxies explicitly will return "Proxy" for
their tag. Same problem though.
In what other ways the ship has sailed?
At least regular objects and arrays can be faithfully interchanged I
think, no? Things get complicated with Date/WeakMap/etc because of
private state, but I remain hopeful a solution can be found in the ES7
timeframe (or whatever the next iteration is called).
I'm not sure about proxy returning "Proxy" as tag name. Is that a good
idea? Brand feels like something that could safely transparently cross
proxies.
David
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss