JS Update Object Properties
Syntax
Object properties in JavaScript can be updated using dot notation or bracket notation.
objectName.key = newValue; // Using dot notationobjectName["key"] = newValue; // Using bracket notationExample
let person = { name: "Alice", age: 30, isStudent: false};
person.age = 31; // Update using dot notationperson["isStudent"] = true; // Update using bracket notation
console.log(person);// Outputs: {name: "Alice", age: 31, isStudent: true}
person.job = "Engineer"; // Adds a new propertyconsole.log(person); // Outputs: {name: "Alice", age: 30, isStudent: true, job: "Engineer"}