Delete Property of JavaScript Object Example



This JavaScript example shows how to delete a property from an existing JavaScript object.

We use delete keyword to remove a property of an object in JavaScript.

Delete Property of JavaScript Object Example

The delete keyword deletes a property from an object:
var user = {
    firstName : 'Ramesh',
    lastName : 'Fadatare',
    emailId : 'ramesh@gmail.com',
    age : 29
}

delete user.age;
console.log(user);
Output:
{firstName: "Ramesh", lastName: "Fadatare", emailId: "ramesh@gmail.com"}
Note that in the above example, we have removed age property of a user object:

delete user.age;

Comments