Reputation:
I am following an online tutorial and I am at a prototype section. My alert
comes back with
function() { return this.brand + ' ' + this.model; }
Anyone know the reason?
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);
Upvotes: 0
Views: 62
Reputation: 88408
s.fullName is the function itself. If you wanted to call this function you would have to write s.fullName().
Upvotes: 3