Remove object from array of objects

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); });

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)