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

Tom Van Cutsem at
Wed Nov 12 23:34:47 PST 2014

2014-11-13 8:18 GMT+01:00 Andreas Rossberg <rossberg at>:

> On 12 November 2014 17:23, Tom Van Cutsem < at> wrote:
> > My opinion is that array testing is fundamental to core JS and is
> > worth the exception.
> This change would only make sense if we also were to special-case all
> other places in the spec that currently say "if O is an exotic Array
> object, ..." to magically handle proxies. Otherwise, all you get is a
> predicate that gives a misleading result.

Yes, good point. See my just-recent post on Array.prototype.concat.

> However, I don't think we want to special-case all those places. That
> would put us on a very slippery slope.

A cursory look at the spec reveals the following built-ins that test for
"exotic Arrays":

- Array.isArray
- Array.prototype.concat
- Array.prototype.filter
- Array.prototype.slice
- Array.prototype.splice
- JSON.parse
- JSON.stringify
- Object.prototype.toString

filter, map, slice and splice didn't used to test for arrays in ES5. They
seem to test for arrays such that the new array they create derives from
the same realm. This can probably be made to work with proxies-for-arrays,
but I'm not sure it is necessary or desirable.

For JSON.stringify, the question is whether a proxy-for-array should
serialize as "[]" vs "{}". Obviously, if Array.isArray(proxyForArray), I
would expect it to serialize as "[]".

For toString, proxies could still implement @@toStringTag to be able to
intercept that call. At this point, I believe would return "[object

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list