JSFiddle - React, Tailwind, and code Playground
JavaScript
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];
Array.prototype.remove = function (object, comparer) {
if (!comparer) {
comparer = function (o1, o2) {
return o1 === o2;
};
}
var index = -1;
for (var i = 0, len = this.length; i < len; ++i) {
if (i in this && comparer(this[i], object)) {
index = i;
}
}
if (index > -1) {
array.splice(index, 1);
}
};
console.log(array);
array.remove(object3, function (o1, o2) {
return o1.id == o2.id && o1.color == o2.color;
});
console.log(array);