JSFiddle - React, Tailwind, and code Playground
JavaScript
var inherits = function (constructor, superConstructor) {
constructor.prototype = Object.create(superConstructor.prototype, {
constructor: {
value: constructor,
enumerable: false
},
super_:{
value: superConstructor.prototype,
enumerable: false
}
});
};
// "class" A
function A(name){
console.log('constructor A');
}
A.prototype.test = function(){
console.log('test A');
}
inherits(B,A);
// "class" B
function B(){
this.super_.constructor.call(this);
console.log('constructor B');
}
B.prototype.test = function(){
this.super_.test.call(this);
console.log('test B');
}
var b = new B();
b.test();