JSFiddle - React, Tailwind, and code Playground
JavaScript
function log(s) {
document.getElementById("log").innerHTML+=s+"<br/>\n";
}
function Parent(x) {
var private = x;
Parent.prototype.get_private=function() {
private_method();
return private;
};
function private_method() {
log("Private method on parent.");
}
}
function Child(x,y) {
Parent.call(this, x);
var private = y;
Child.prototype.get_private=function() {
private_method();
return private;
};
function private_method() {
log("Private method on child.");
}
this.get_parent_private=function() {
return Parent.prototype.get_private.call(this);
};
}
var p=new Parent(1);
log("p.get_private(): " + p.get_private());
var c=new Child(2,3);
log("c.get_private(): " + c.get_private());
log("c.get_parent_private(): " + c.get_parent_private());