Tag: google chrome

如何撤消Object.defineProperty调用?

小提琴 var Assertion = function() { return { "dummy": "data" }; } Object.defineProperty(Object.prototype, 'should', { set: function(){}, get: function(){ return new Assertion(this); } }); // Insert magic here. // This needs to be false console.log(({}).should === undefined); 我有什么select在ES5中撤销defineProperty调用? 没有愚蠢的build议像Object.defineProperty = function() { }请。 下面的Object.defineProperty(Object.prototype, 'should', {}) 不起作用 和Object.defineProperty(Object.prototype, 'should', { value: undefined }) 抛出一个Uncaught TypeError: […]