Question about proxies and non-class inheritance with private fields
Oriol _
oriol-bugzilla at hotmail.com
Sun Aug 27 19:43:12 UTC 2017
A proxy object emulates its target because the essential internal methods are redirected to the target by default.
However, this does not happen with other internal slots, so I don't see why it should be different for private fields.
More examples:
```js
new Number(123).valueOf(); // 123
new Proxy(new Number(123), {}).valueOf(); // TypeError: valueOf method called on incompatible Proxy
```
```js
new Set().has(1); // false
new Proxy(new Set(), {}).has(1); // TypeError: has method called on incompatible Proxy
```
```js
// Assuming a web browser
document.nodeType; // 9
new Proxy(document, {}).nodeType; // TypeError: 'get nodeType' called on an object that does not implement interface Node.
```
--Oriol
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170827/6da3f0d9/attachment.html>
More information about the es-discuss
mailing list