タグ

ブックマーク / gist.github.com/yoshimuraYuu (1)

  • JavaScriptの継承について

    // 基底クラス function f () { this.f_has = "f_has"; } // 基底クラスのprototypeを設定 f.prototype.f_proto = "f_proto"; // サイの手法で継承 function F () { this.F_has = "F_has"; } F.prototype = Object.create(f.prototype); F.prototype.constructor = F; // ウェッブの手法で継承 function G () { this.G_has = "G_has"; } G.prototype = new f(); TestCase("inherit test", { setUp : function () { this.F = new F(); this.G = new G(); }, "test i

    riywo
    riywo 2013/08/05
  • 1