var fn = function() {
this.method1 = function() {
return this.public;
};
this.method2 = function() {
return {
init: function() { return this.public; }
}
};
fn.prototype.public = "method prototype";
};
创建对象 fn
var object = new fn();
object.method1() // "method prototype"
object.method2().init(); // undefined
this.public 原型在 method2().init() 函数运行返回未定义?
有没有原型的替代品?谢谢你。