Calling toString on function proxy throws TypeError exception

Brian Terlson Brian.Terlson at
Thu Oct 22 18:18:38 UTC 2015

Proxies without handlers are not indistinguishable from their targets. There are many examples, eg. `let p = new Proxy(new Map(), {}); p.set(1, 1);` also throws.

From: es-discuss [mailto:es-discuss-bounces at] On Behalf Of Thomas Greiner
Sent: Thursday, October 22, 2015 4:39 AM
To: es-discuss <es-discuss at>
Subject: Calling toString on function proxy throws TypeError exception

According to<> `Function.prototype.toString` is supposed to throw a `TypeError` exception when used on a function proxy. That's also consistent with how it's defined at<> but presumably only because the Proxy scenario is not explicitly mentioned.

The problem I see with that is that it makes proxies distinguishable from their targets even if they don't specify any traps. At least in cases where the mere existence of a proxy needs to be kept secret, this introduces a severe limitation.

That behavior also goes against the "transparent virtualization" principle as outlined by Axel Rauschmayer (see<>):

> Proxies are shielded in two ways:
> - It is impossible to determine whether an object is a proxy or not (transparent virtualization).
> - You can’t access a handler via its proxy (handler encapsulation).

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

More information about the es-discuss mailing list