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

by Arnaud Buchholz

HTML

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

JavaScript

function OldA () {
  this._a = "A";
}

OldA.prototype.a = function () {
  return this._a;
};

var a = new OldA();
assert(() => a instanceof OldA);
assert(() => a.a() === "A");

function OldB () {
  this._b = "B"; // Use this before it was properly built
  OldA.apply(this, arguments);
}

OldB.prototype = Object.create(OldA.prototype);

OldB.prototype.b = function () {
  return this._b;
};

var b = new OldB();
assert(() => b instanceof OldA);
assert(() => b.a() === "A");
assert(() => b instanceof OldB);
assert(() => b.b() === "B");