How to remove a property from a JavaScript object

Hello guys,

Javascript object is pair of key/value. If you want to access any value from the Javscript object, you can access using object.key or object['key'] syntax.

In this article we will share how you can remove any property from the Javscript object. 

Here is below code to remove property from the Javscript object.

var person = {
    firstName: "John",
    lastName: "Doe",
    email: "^[email protected]"
};
delete person.email;

// or another way
delete person['email'];

console.log(person);

This way you can remove property from Javascript object.

Thank you for giving time to read the article. I hope you like this article.

Tags: