JSFiddle - React, Tailwind, and code Playground
JavaScript
var obj = {
"results": [{
"id": "460",
"name": "Widget 1",
"loc": "Shed"
}, {
"id": "461",
"name": "Widget 2",
"loc": "Kitchen"
}, {
"id": "462",
"name": "Widget 3",
"loc": "bath"
}]
};
var removeItem = obj.results.filter(function (val) {
return val.id !== "460";
});
function removeFunction(myObjects, prop, valu) {
var newArray = myObjects.filter(function (val) {
return val[prop] !== valu;
});
return newArray;
}
//alert(valuesWith460[0].name);
console.log(removeFunction(obj.results, "name", "Widget 3"));