How I learned from a crazy idea / Notable differences (ES6 way)

by Arnaud Buchholz

HTML

<script src="https://arnaudbuchholz.github.io/blog/jsfiddle-assert.js"></script>

JavaScript

alert(0);
class Es6A {
  constructor () {
    this._a = "A";
  }

  a () {
    return this._a;
  }
}

alert(1);
class Es6B extends Es6A {
  constructor () {
    this._b = "B";  // Use this before it was properly built
    super();
  }

  b () {
    return this._b;
  }
}
alert(2);

var b = new Es6B();
assert(() => b instanceof Es6A);
assert(() => b.a() === "A");
assert(() => b instanceof Es6B);
assert(() => b.b() === "B");