我读了一本电子书并找到了这个命令,但我不知道它的用途以及何时使用它。例子:
var x = (12, 34, 56)
在这种情况下,x 是一个数字,它的值为 56。谢谢。
这是我从电子书 'Javascript for absolute Beginners' 中读到的完整脚本:
var fridge = {
buttermilk: [1/3, "cup"],
kefir: [1 + 1/2, "cup"],
yogurt: [4, "cup"],
};
var dough = {
hardWhiteWholeWheatFlour: [2, "cup"],
sugar: [1/3, "cup"],
madagascarVanilla: [1, "tsp"],
orangeZest: [1, "tbs"],
soda: [1, "tsp"],
tartar: [1, "tsp"],
orangeJuice: [1/2, "cup"],
culturedMilk: [1/2, "cup"],
egg: [1],
cranberries: [2/3, "cup"]
};
dough.culturedMilk[0] = fridge.buttermilk[0] >= 1/2 ? (fridge.buttermilk[0] -= 1/2, 1/2) :
fridge.kefir[0] >= 9/16 ? (fridge.kefir[0] -= 9/16, 9/16) :
fridge.yogurt[0] >= 10/16 ? (fridge.yogurt[0] -= 10/16, 10/16) :
alert("No cranberry bread for you!");
dough.culturedMilk;
// [0.5625, "cup"]
fridge.kefir;
// [0.9375, "cup"]