JSFiddle - React, Tailwind, and code Playground
JavaScript
var Parent = function () {};
Parent.prototype.myF = function () {
console.log('derp');
};
function Child() {
Parent.call(this);
//the key is that the value of this when calling the constructor is the class instance, not the class itself.
this.class_= Object.getPrototypeOf(this);
this.SuperClass= Object.getPrototypeOf(this.class_)
};
//make [[prototype]] of Child be a ref to Parent.prototype
Child.prototype = Object.create(Parent.prototype);
//need to explicitly set the constructor
Child.prototype.constructor = Child;
Child.prototype.myF = function () {
//Could do it here, but cleaner to do it in the constructor.
//var class_ = Object.getPrototypeOf(this);
//var SuperClass = Object.getPrototypeOf(class_);
this.SuperClass.myF.call(this);
console.log("did I derp??");
};
childInstance = new Child();
childInstance.myF();