How To Clone A Prototype With Property Methods?
I am using the Typed.React library which includes a method to extend one prototype definition with that of another: function extractPrototype(clazz) { var proto = {}; for (
Solution 1:
I think you are looking for the new ES6 Object.assign
function.
Of course there's a simpler fix to your problem - just don't access and set properties, copy their property descriptors:
functionextractPrototype(clazz) {
var proto = {};
for (var key in clazz.prototype) {
Object.defineProperty(proto, key, Object.getOwnPropertyDescriptor(clazz.prototype, key));
}
return proto;
}
Post a Comment for "How To Clone A Prototype With Property Methods?"