2014-11-14 21:52 GMT+01:00 Jeremy Martin <[email protected]>:
> 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.
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss