'Javascript: The Good Parts'
「コンストラクター呼び出しパターン」(29-30ページ)に関するこの例を示します。
var Quo = function (string) {
this.status = string;
};
Quo.prototype.get_status = function() {
return this.status;
};
var myQuo = new Quo("confused");
document.writeln(myQuo.get_status()); // returns confused
セクションは、で終わります"Use of this style of constructor functions is not recommended. We will see better alternatives in the next chapter."
例のポイントと、このパターンの使用に対する強力な推奨事項は何ですか?
ありがとう。