How I learned from a crazy idea / Subclassing an ES6 class in an 'old' class
by Arnaud Buchholz
HTML
<script src="https://arnaudbuchholz.github.io/blog/jsfiddle-assert.js"></script>
JavaScript
class Es6A {
constructor () {
this._a = "A";
}
a () {
return this._a;
}
}
function ExtendEs6WithOldB () {
Es6A.apply(this, arguments);
this._b = "B";
}
ExtendEs6WithOldB.prototype = Object.create(Es6A.prototype);
ExtendEs6WithOldB.prototype.b = function () {
return this._b;
};
var b = new ExtendEs6WithOldB();
assert(() => b instanceof Es6A);
assert(() => b.a() === "A");
assert(() => b instanceof ExtendEs6WithOldB);
assert(() => b.b() === "B");