JSFiddle - React, Tailwind, and code Playground
JavaScript
function indexOf(arr, val, comparer) {
for (var i = 0, len = arr.length; i < len; ++i) {
if ( i in arr && comparer(arr[i], val) ) {
return i;
}
}
return -1;
}
var object1 = new Object(),
object2 = new Object(),
object3 = new Object();
object1.id = 1;
object1.color = "red";
object2.id = 2;
object2.color = "blue";
object3.id = 2;
object3.color = "blue";
var array = [object1, object2];
var index = indexOf(array,object3, function(o1,o2) { return o1.id == o2.id && o1.color == o2.color; });
if (index > -1) {
array.splice(index, 1);
}
console.log(array);