📌  相关文章
📜  如何在javascript代码示例中将项目添加到对象

📅  最后修改于: 2022-03-11 15:01:48.711000             🧑  作者: Mango

代码示例2
var element = {}, cart = [];
element.id = id;
element.quantity = quantity;
cart.push(element);

// Array of Objects in form {element: {id: 10, quantity: 10} }
var element = {}, cart = [];
element.id = id;
element.quantity = quantity;
cart.push({element: element});