I have an array of objects:
[{\"value\":\"14\",\"label\":\"7\"},{\"value\":\"14\",\"label\":\"7\"},{\"value\":\"18\",\"label\":\"7\"}]
How I ca
In ES6 (or using es6-shim) you can use Array.prototype.findIndex along with Array.prototype.splice:
arr.splice(arr.findIndex(matchesEl), 1);
function matchesEl(el) {
return el.value === '14' && el.label === '7';
}
Or if a copy of the array is ok (and available since ES5), Array.prototype.filter's the way to go:
var withoutEl = arr.filter(function (el) { return !matchesEl(el); });