add property on object js code example
Example 1: Add New Properties to a JavaScript Object
var myDog = {
"name": "Happy Coder",
"legs": 4,
"tails": 1,
"friends": ["freeCodeCamp Campers"]
};
myDog.bark = "woof";
// or
myDog["bark"] = "woof";
Example 2: add property with value in js
var myObject = {
sProp: 'some string value',
numProp: 2,
bProp: false
};