Array.isArray(new Proxy([], {})) should be false (Bug 1096753)
Tom Van Cutsem
tomvc.be at gmail.com
Fri Nov 14 13:01:28 PST 2014
2014-11-14 21:52 GMT+01:00 Jeremy Martin <jmar777 at gmail.com>:
> Allen's previous comments:
>
> Proxies are not transparent forwarders! In particular their default
>> handling of the `this` value on method invokes will break any built-in
>> method that needs to access "internal slots" of an object.
>
>
> ...lead me to believe that this isn't the case for proxified Arrays, so
> I'd have to reverse my earlier position, as `Array.isArray(proxifiedArray)`
> evaluating to true just seems likely to break code.
>
For the particular case of Arrays though, because Array methods were
carefully specified to be generic (i.e. to also work on non-array objects),
they will work just fine on proxies-for-arrays:
var p = new Proxy([1,2,3] , {} );
var a = p.map(function(x) { return x + 1; });
console.log(a); // [2,3,4]
So, of all the exotic objects in the ES and WebIDL specs, Arrays are
probably one of the few exceptions where a Proxy wrapper *is* transparent
by default.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20141114/2ca083ea/attachment.html>
More information about the es-discuss
mailing list