This example demonstrates how to add a new property to an object.
// Create an Object: const person = { firstName: “John”, lastName : “Doe”, language : “EN” }; // Add a Property Object.defineProperty(person, “year”, {value:“2008”}); |
This example updates the value of a property.
// Create an Object: const person = { firstName: “John”, lastName : “Doe”, language : “EN” }; // Change a Property Object.defineProperty(person, “language”, {value : “NO”}); |