Way To Remove A Property From An Object In JavaScript

Hello devs,

In this javascript quick example, I will show you how to remove object property from javascript object. So from this tutorial, You will learn how to remove property from object in JavaScrpt. I will share source code of removing object property in JavaScript.

We can use delete object.key or object['key'] syntax to delete property from an object in javascript. So see the below code to remove property from the JavaScript object.

Example code:

var person = {
    firstName: "John",
    lastName: "Doe",
    email: "^johndoe@gmail.com"
delete person.email;

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



Read also: Difference Between let and var and const in JavaCcript


Hope it can help you.