How do I remove the property p
from the object's prototype?
var Test = function() {};
Object.defineProperty(Test.prototype, 'p', {
get: function () { return 5; }
});
Object.defineProperty(Test.prototype, 'p', {
get: function () { return 10; }
});
This produces TypeError: Cannot redefine property: p. Is there a way I can remove the property and re-add it? Or is it possible to set the configurable
attribute after the property was created?
function MyTest(){ t = new Test(); t.p = ...; return t; }
– PhotomapObject.defineProperty
itself this is impossible. – Photomapvar oldTest = Test; Test = function(){ var t = new oldTest; t.p = 10; return t;}
– Photomap