📌  相关文章
📜  如何在 js 中向对象添加字段 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:18.491000             🧑  作者: 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});