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

Tom Van Cutsem at
Mon Nov 17 22:58:47 PST 2014

2014-11-17 18:30 GMT+01:00 Allen Wirfs-Brock <allen at>:

> But probing through the proxy as has been proposed is a terrible violation
> of the MOP API boundary and isn't generalizable to other built-ins that are
> dependent upon internal state. While a null handler proxy on a direct
> instance of Array would work under that design, a comparable Map.isMap or
> Promise.isPromise method would not.  Rather than a one-off hack I think we
> should use a new pattern that is generalizable:

If we can find consensus on this much more general pattern of type-testing
by using a symbol on the constructor, I'm all for it. +1!
I also think we don't want to special-case Proxies in the proposed
type-testing algorithm.

That said, if we cannot come to a consensus on this more generic form of
type-testing, I would still defend the position that Array.isArray merits
an exception (compared to Map.isMap/Promise.isPromise etc.) *precisely
because* Arrays were carefully defined not to depend on any special
instance state. In this scenario, repurposing the @@isConcatSpreadable
symbol seems like the most obvious thing to do (it currently feels terribly
ad-hoc, making it something more generic such as @@isArrayLike makes more
sense to me)

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

More information about the es-discuss mailing list