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:
- Declare a variable named
userand initialize it with an object literal containing a single property whose key isfirstNameand value is the string"John". - Extend the
userobject with a new property whose key islastNameand value is the string"Doe"using the dot notation. - Extend the
userobject with a new property whose key isemailand 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