JSFiddle - React, Tailwind, and code Playground
JavaScript
console.clear();
var L1 = {};
L1.Foo = function() {/*...*/};
L1.Bar = function() {/*...*/};
//...
L1.Baz = function() {/*...*/};
var L2 = {
Foo: function() {
L1.Foo.apply(this, arguments);
this.someOtherProperty = "foo";
}
// …other overwritten constructors
};
for (var prop in L1) {
if (!L2[prop]) {// unless overridden above, create default that only…
(function(prop) {
L2[prop] = function() {
L1[prop].apply(this, arguments); // …calls super
};
})(prop);
}
L2[prop].prototype = Object.create(L1[prop].prototype);
L2[prop].prototype.constructor = L2[prop];
}
var foo = new L2.Foo();
console.log(foo); //L2.Foo - correct!
console.log(foo.someOtherProperty); //foo - correct!
var bar = new L2.Bar();
console.log(bar); //L2.(anonymous function)?
var baz = new L2.Baz();
console.log(baz); //L2.(anonymous function)?