We have seen how we can access properties with dot notation or bracket notation:
We can use the same syntax to perform other operations on object properties.
Updating Properties
We can use dot notation or bracket notation to update properties:
const person = {
name: 'John Doe',
age: 22,
};
person.age++;
console.log(person.age);
person.name += ' Sr.';
console.log(person['name']);
Adding Properties
We can even add new properties:
const person = {
name: 'Jane Doe',
age: 22,
};
person.job = 'Game Developer';
console.log(person);