How I learned from a crazy idea / The ES6 way
HTML
<script src="https://arnaudbuchholz.github.io/blog/jsfiddle-assert.js"></script>
JavaScript
class Es6A {
constructor () {
this._a = "A";
}
a () {
return this._a;
}
}
class Es6B extends Es6A {
constructor () {
super();
this._b = "B";
}
b () {
return this._b;
}
}
var b = new Es6B();
assert(() => b instanceof Es6A);
assert(() => b.a() === "A");
assert(() => b instanceof Es6B);
assert(() => b.b() === "B");