Essential JavaScript

Going Further

Updating Properties

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);

Learning Goals

  • I can update properties on an object

  • I can add new properties to an object

Code Editor

Click "Run Code" to execute your JavaScript in a secure sandbox and see the output below.

Console Output

// Console output will appear here...

0 output lines