Created
May 5, 2014 17:29
-
-
Save johnjbarton/f8a837104f0292fa088c to your computer and use it in GitHub Desktop.
Proxy fails in Object.create()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="../third_party/harmony-reflect/reflect.js"></script> | |
<script name="testObjectCreate"> | |
(function() { | |
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); | |
console.log('hasProxyAsProto.__proto__: ', | |
hasProxyAsProto.__proto__); | |
console.log('hasProxyAsProto.__proto__ === aProxy ', | |
hasProxyAsProto.__proto__ === aProxy); | |
console.log('Object.getPrototypeOf(hasProxyAsProto) === aProxy ', | |
Object.getPrototypeOf(hasProxyAsProto) === aProxy); | |
console.log('hasProxyAsProto.__proto__ === aProxy.__proto__ ', | |
hasProxyAsProto.__proto__ === aProxy.__proto__); | |
console.log('--- Contrast with non-proxy results: ---') | |
var hasAPrototypeAsProto = Object.create(aPrototype); | |
console.log('hasAPrototypeAsProto.__proto__', | |
hasAPrototypeAsProto.__proto__); | |
console.log('hasAPrototypeAsProto.__proto__ === aPrototype ', | |
hasAPrototypeAsProto.__proto__ === aPrototype); | |
console.log('Object.getPrototypeOf(hasAPrototypeAsProto) === aPrototype ', | |
Object.getPrototypeOf(hasAPrototypeAsProto) === aPrototype); | |
console.log('hasAPrototypeAsProto.__proto__ === aPrototype.__proto__ ', | |
hasAPrototypeAsProto.__proto__ === aPrototype.__proto__); | |
})(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment