javascript set property of object code example
Example 1: JavaScript: Updating Object Properties
var myDog = {
"name": "Coder",
"legs": 4,
"tails": 1,
"friends": ["freeCodeCamp Campers"]
};
myDog.name = "Happy Coder";
Example 2: js change value in object
var object = { boo:true, baa:5 };
console.log(object);
function change() {
object.boo = false;
object.baa++;
};
change();
console.log(object);
Example 3: add property to object javascript
let yourObject = {};
let yourKeyVariable = "yourKey";
yourObject[yourKeyVariable] = "yourValue";
yourObject["yourKey"] = "yourValue";
yourObject.yourKey = "yourValue";
Example 4: object set js
let nombres = [10, 45, 75, 10 ,24,45 ] ;
let monSet = new Set() ;
monSet.add('100') ;
monSet.add('280') ;
console.log(monSet.size) ;