function Foo (name) {
this.name = name;
}
Foo.prototype.bar = {
n: function() {
// How to get here after initializing the object foo?
}
};
var a = new Foo('John');
console.log(a.bar.n())
如何在初始化对象foo后进入此处?初始化后获取原型对象的属性
这种模式通常不会被利用,因为您需要跳过一些箍环才能使其工作。是不是真正的惯用JavaScript。 –
我知道,但仍然.. – Aleksandr
你是什么意思的“如何到达这里?” – rsp