Hello Friends đź‘‹,

Welcome to Infinitbility.

To remove the item from a JSON object in javascript, use the delete keyword it will remove the key-value pair from an object only you have to mention the delete keyword with the key.

JavaScript object is one of the most used concepts and we will use it every day almost but sometimes we need to delete some key-value pair.

Today, we will see how we can remove items from the javascript object using a key.

Talk is cheap, Show me code.

JavaScript provides a delete operator to remove the item from the object we have to just write the object with the key name and it will remove the property.

let’s take a sample object like below.

let exampleObject = {
  id: 1,
  name: "infinitbility",
  error: "Feild required"
};

Now, we delete the error property from the object.

let exampleObject = {
  id: 1,
  name: "infinitbility",
  error: "Feild required"
};

console.log("exampleObject", exampleObject);

delete exampleObject.error;

console.log("exampleObject", exampleObject);

I hope it helps you, All the best đź‘Ť.