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