-
-
Save isaacs/7162983 to your computer and use it in GitHub Desktop.
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
function def() { | |
var myx; | |
Object.defineProperty(global, 'x', { | |
get: function() { | |
return myx; | |
}, | |
set: function(val) { | |
console.log('setter!'); | |
myx = val; | |
}, | |
configurable: true, | |
enumerable: true | |
}); | |
// This one is fine. | |
this.eval('var x = function y() {}'); | |
console.log(myx.name, this.x.name); | |
// This one throws a redeclaration error if we didn't | |
// set configurable:true in the property. However, | |
// wtf? Doesn't call the setter!? | |
this.eval('function x() {}'); | |
console.log(myx.name, this.x.name); | |
} | |
def(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment