JSFiddle - React, Tailwind, and code Playground
by Ali Soltani
JavaScript
Array.prototype.remove = function(elem) {
var indexElement = this.findIndex(el => el.name === elem.name);
console.log(indexElement);
if (indexElement != -1)
this.splice(indexElement, 1);
return this;
};
var data = [{
"name": "abc",
"age": 25,
"school": "xyz pqr"
},
{
"name": "abc1",
"age": 26,
"school": "xyz pqr"
},
{
"name": "abc2",
"age": 27,
"school": "xyz pqr"
}]
var dList = [{
"name": "abc",
"age": 25,
"school": "xyz pqr",
}]
data.remove(dList[0]);
console.log(data);