JSFiddle - React, Tailwind, and code Playground
JavaScript
// Console.log for JSFiddle
var console = {log: function(str) { document.write(str+"<br>"); }};
function Parent() {}
Parent.tableName = 'parentTable';
Parent.prototype.static_method = function() {
return this.constructor.tableName;
}
function Child() {}
Child.tableName = 'childTable';
// Implementation of nodeJS util.inherits
Child.super_ = Parent;
Child.prototype = Object.create(Parent.prototype, {
constructor: { value: Child, enumerable: false }
});
var p = new Parent();
var c = new Child();
/*** Static Method called properly ***/
console.log(Parent.prototype.static_method());
console.log(Child.prototype.static_method());
/*** Static Method called "wrongly" ***/
console.log(p.static_method());
console.log(c.static_method());