Proxy .__proto__ is not getPrototypeOf?

John Barton johnjbarton at google.com
Mon May 5 10:40:29 PDT 2014


I'm hoping someone can explain this result which surprises me.

If I create an object with a Proxy-ed prototype, the resulting object does
not obey .__proto__ equal Object.getPrototypeOf().

For example:
  var aPrototype = {foo: 'foo'};
  var handler = {
  get: function(target, name, receiver) {
  console.log('   (Proxy handler \'get\' called for name = ' + name + ')');
  return target[name];
  }
  };
  var aProxy = Proxy(aPrototype, handler);
  var hasProxyAsProto = Object.create(aProxy);

At this point, I expected
  hasProxyAsProto.__proto__ === aProxy
but it it not true.  Moreover, the operation
  hasProxyAsProto.__proto__
calls the Proxy handler get function with name === '__proto__': that makes
no sense as hasProxyAsProto is not a Proxy.

I tried this on Firefox 29 and Chrome 36.  Complete example is here:
https://gist.github.com/johnjbarton/f8a837104f0292fa088c

Any ideas?
jjb
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140505/562c5ffb/attachment.html>


More information about the es-discuss mailing list