我怎样才能展示"巨无霸"
这demo使它看起来应该可行。不知道我哪里出错了。
function sandwich(name, price, quantity, meal) {
this.name = "Default Sandwich";
this.price = 0.00;
this.quantity = 0;
this.meal = false;
}
var burger = new sandwich("Big Mac", 1.25, 1, false);
document.getElementById("demo").innerHTML = burger.name;

<div id="demo">
</div>
&#13;
答案 0 :(得分:2)
您只需要更改sandwich()
功能:
function sandwich(name, price, quantity, meal) {
this.name = name;
this.price = price;
this.quantity = quantity;
this.meal = meal;
}