Array.isArray(new Proxy([], {})) should be false (Bug 1096753)

Allen Wirfs-Brock allen at wirfs-brock.com
Fri Nov 14 09:06:23 PST 2014


On Nov 13, 2014, at 5:02 PM, Brendan Eich wrote:

> Allen Wirfs-Brock wrote:
>> We might redefine Array.isArray to be based upon testing for @@isConcatSpreadable but that potentially would give different results for legacy uses that did __proto__ hacking such as I mentioned in my previous mote.
> 
> How about we turn the @@ property into @@isArrayLike or @@isStronglyArrayLike if you insist.

This could be done, but that property could pre-exist on Array prototype.  If it did, it would change the behavior (probably including the JSON.stringify behavior) of existing code that puts Array.prototype on its [[Prototype]] chain.

The definition of Array.isArray(obj) would be roughly:

1. Let isArray be ToBoolean(Get(obj, @@isArrayLike));
2. If isArray is true, then return true;
3. If obj is an exotic array object, then return true;
4. return false

Allen



More information about the es-discuss mailing list