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'];

console.log(person);

 

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

 

Hope it can help you.

 

Facebook Github
A web enthusiastic, a self-motivated full-stack software engineer from Dhaka, Bangladesh with experience in developing applications using Laravel , React and Vue js