Redefine Object.defineProperty in Javascript
- by kwicher
I would like to learn if it is possible to redefine the "definePropery" function of the Object(.prototype) in a subclass(.prototype) so that the setter not only sets the value of the property but also eg executes an additional method.
I have tried something like that:
Myclass.prototype.defineProperty = function (obj, prop, meth) {
Object.defineProperty.call(this, obj, prop, {
get: function () {
return obj[prop]
},
set: function () {
obj[prop] = n;
alert("dev")
}
})
}
But id does not work