JSFiddle - React, Tailwind, and code Playground
JavaScript
var Parent = function() {};
Object.defineProperty(Parent.prototype,"type", {
value: function() { return 'Parent'; }
});
var oParent = new Parent();
var Child1 = function() {};
Child1.prototype = Object.create(Parent.prototype, {
type: {
value: function() { return 'Child1'; }
}
});
var oChild1 = new Child1();
var Child2 = function() {};
Child2.prototype = Object.create(Parent.prototype);
Object.defineProperty(Child2.prototype, 'type', {
value: function() { return 'Child2'; }
});
var oChild2 = new Child2();
var Child3 = function() {};
Child3.prototype = Object.create(Parent.prototype);
var oChild3 = new Child3();
oChild3.type = function() { return 'Child3'; };
var Child4 = function() {};
Child4.prototype = Object.create(Parent.prototype);
Child4.prototype.type = function() { return 'Child4'; };
var oChild4 = new Child4();
console.log('----');
console.log('parent', oParent.type());
console.log('child1', oChild1.type());
console.log('child2', oChild2.type());
console.log('child3', oChild3.type());
console.log('child4', oChild4.type());
Object.defineProperty(Parent.prototype,"type", {
value: function() { return 'Parent2'; },
configurable: false
});
var oParent2 = new Parent();
console.log('parent2',oParent2.type());