how to you add to an object javascript code example
Example 1: how to add property to object in javascript
var data = {
'PropertyA': 1,
'PropertyB': 2,
'PropertyC': 3
};
data["PropertyD"] = 4;
// dialog box with 4 in it
alert(data.PropertyD);
alert(data["PropertyD"]);
Example 2: js add data in object
var element = {}, cart = [];
element.id = id;
element.quantity = quantity;
cart.push(element);