'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."
这个例子的意义何在?强烈建议不要使用这种模式?
谢谢。