Update & Delete Object Properties in JavaScript

3 min read·Jan 1, 2026

Update object properties

To add an additional property to an object after its creation or update an existing one, you can use the dot syntax as follows:

object.key = value;

Or the square brackets syntax as follows:

object["property"] = value;

Example

Let's consider this script:

create_user.js
let user = {
  firstName: "John"
};

user.lastName = "Doe";
user["email"] = "jdoe@mail.com";

console.log(user);

When executed, it will:

  1. Declare a variable named user and initialize it with an object literal containing a single property whose key is firstName and value is the string "John".
  2. Extend the user object with a new property whose key is lastName and value is the string "Doe" using the dot notation.
  3. Extend the user object with a new property whose key is email and value is the string "jdoe@mail.com" using the square brackets notation.

Which will produce this output:

$ node create_user.js
{ firstName: 'John', lastName: 'Doe', email: 'jdoe@test.com' }

Delete object properties

To delete a property from an object, including all of its nested properties, you can use the delete keyword as follows:

delete object.key

Enjoying the courses?

I've made these courses completely free so anyone can learn from them. If they've helped you and you'd like to actively support the work behind BackendBrewery, you can leave a tip:

Support BackendBrewery
Update & Delete Object Properties in JavaScript | Backend Brewery