我正在关注在线教程,我正处于原型部分。我的alert
回来了
function() { return this.brand + ' ' + this.model; }
有人知道原因吗?
function Car(model, brand) {
this.model = model;
this.brand = brand;
}
Car.prototype.fullName = function() {
return this.brand + ' ' + this.model;
}
var s = new Car("G5", "Pontiac");
var full = s.fullName;
alert(full);
答案 0 :(得分:3)
s.fullName是函数本身。如果你想调用这个函数,你必须写s.fullName()。