如何将函数数组传递给js函数

时间:2017-03-18 06:22:44

标签: javascript

我怎样才能展示"巨无霸"

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;
&#13;
&#13;

1 个答案:

答案 0 :(得分:2)

您只需要更改sandwich()功能:

function sandwich(name, price, quantity, meal) {
  this.name = name;
  this.price = price;
  this.quantity = quantity;
  this.meal = meal;
}