Proxies fail comparison operator

Oriol _ oriol-bugzilla at hotmail.com
Thu Mar 30 20:00:46 UTC 2017


> Isn't the purpose of the proxy to be exchanged with the original, without any negative side effects?

This is not possible. Proxies do not reflect internal slots, so for example, in a browser,

```js
var obj = document;
var proxy = new Proxy(obj, {});
Node.prototype.contains.call(obj, obj); // true
Node.prototype.contains.call(proxy, proxy); // TypeError: 'contains' called on an object that does not implement interface Node.
```

So it would be bad if `obj === proxy` returned true but the values had different behaviors. I think `+0 === -0` despite `1/+0 !== 1/-0` is already enough of a nightmare.

--Oriol
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170330/d487a364/attachment.html>


More information about the es-discuss mailing list