To modify a property in JavaScript, you can use dot notation or bracket notation to assign the new value to the existing property.
let obj = {
name: 'Krunal',
age: 27,
education: 'Engineer'
};
console.log(obj)
obj['age'] = 26;
obj['name'] = 'Ankit';
console.log('After modifying a property using square bracket');
console.log(obj);
Output
{ name: 'Krunal', age: 27, education: 'Engineer' }
After modifying a property using square bracket
{ name: 'Ankit', age: 26, education: 'Engineer' }
To change a value of the existing property of an object, specify the object name followed by a square bracket, the name of the property you wish to change, an equals sign, and the new value you want to assign.
You can also use the dot syntax to attach the new values to the existing properties or change the values of existing properties.