how to remove element in object in javascript code example
Example 1: How can I remove a specific item from an array
const array = [2, 5, 9];
console.log(array);
const index = array.indexOf(5);
if (index > -1) {
array.splice(index, 1);
}
console.log(array);
Example 2: javascript remove object key
var obj = {a: 5, b: 3};
delete obj["a"];
console.log(obj);
Example 3: javascript remove element from object
delete object.element
Example 4: js remove key from object
var key = "Cow";
delete thisIsObject[key];
delete thisIsObject["Cow"];
delete thisIsObject.Cow;
Example 5: javascript remove object element
delete object.element;