what is happening under the hood here?
That's an implementation detail of the JS engine.
Is there a standard < ES6 design pattern that simulates class inheritance being invoked
"Standard" is probably going too far, but Babel is a well known transpiler that can convert ES6 to ES5.
It gives this:
'use strict';
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Foo = function Foo() {
_classCallCheck(this, Foo);
this.sayHello = function () {
return console.log('Hello');
};
};
var Bar = function (_Foo) {
_inherits(Bar, _Foo);
function Bar() {
_classCallCheck(this, Bar);
var _this = _possibleConstructorReturn(this, (Bar.__proto__ || Object.getPrototypeOf(Bar)).call(this));
_this.sayGoodbye = function () {
return console.log('Goodbye');
};
return _this;
}
return Bar;
}(Foo);