0
私はオンラインチュートリアルに従っています。私はプロトタイプセクションにあります。私のalert
にはJavaScriptプロトタイピングが動作しない
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);
ええ、あなたは関数ではなくプロパティを呼び出しています。すべての関数はwith()= bracesと呼びます。オハイオ州の権利を – marko
haha。ありがとうございます。回答は –
です@marko:かっこ。中括弧は '{}'です。 – katspaugh