TypeScript and CoffeeScript both use an __extends
function to setup inheritance. Here's the one form TypeScript (CoffeeScript's is very similart).
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
Why do they need function __()
(function ctor()
in CoffeeScript)? Why not set the prototype directly:
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
d.prototype = new b();
};