How Dart classes work as JS
Dartのクラス機構はどんなものか調べた記録。DartはCoffeeScriptよりも遥かに複雑だが、継承メカニズムはほぼ同一だった。
DartからJSにコンパイルされた結果は長いので肝心なところだけ。
function $inherits(child, parent) { if (child.prototype.__proto__) { child.prototype.__proto__ = parent.prototype; } else { function tmp() {}; tmp.prototype = parent.prototype; child.prototype = new tmp(); child.prototype.constructor = child; } }
__proto__はECMA262標準ではないので無視するとしてelseブロックをみると、中間代理クラスtmpがcoffeeのctorとまったく同じ役割である。