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

Andrea Giammarchi andrea.giammarchi at gmail.com
Thu Nov 13 03:25:24 PST 2014


well, Proxy can be a diabolic beast

```js
Object.setPrototypeOf(
  Object.prototype,
  new Proxy(Object.prototype, evilPlan)
)
```

having no way to understand if an object is a Proxy looks like a footgun to
me in the long term, for libraries, and "code alchemists"

You indeed wrote that different Array methods need to know if there's a
Proxy in there ... if dev cannot know the same via code they are unable
again to subclass properly or replicate native behaviors behind magic
internal checks.

If there is a way and I'm missing it, then it's OK

Regards








On Thu, Nov 13, 2014 at 7:15 AM, Tom Van Cutsem <tomvc.be at gmail.com> wrote:

> 2014-11-12 23:49 GMT+01:00 Andrea Giammarchi <andrea.giammarchi at gmail.com>
> :
>
>> If Array.isArray should fail for non "pure" Arrays, can we have a
>> Proxy.isProxy that never fails with proxies ?
>>
>
> We ruled out `Proxy.isProxy` very early on in the design. It's
> antithetical to the desire of keeping proxies transparent. In general, we
> want to discourage type checks like you just wrote.
>
> If you're getting handed an object you don't trust and need very strong
> guarantees on its behavior, you'll need to make a copy. This is true
> regardless of proxies. In your example, even if the array is genuine, there
> may be some pointer alias to the array that can change the array at a later
> time.
>
> Regards,
> Tom
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20141113/5c309cac/attachment-0001.html>


More information about the es-discuss mailing list