だから私は合理的な解決策を見つけましたが、不完全です:
Array.prototype.removeObjWithValue = function(name, value){
var array = $.map(this, function(v,i){
return v[name] === value ? null : v;
});
this.length = 0; //clear original array
this.push.apply(this, array); //push all elements except the one we want to delete
}
Array.prototype.removeObj = function(obj){
var array = $.map(this, function(v,i){
return v["_id"] === obj["_id"] ? null : v;
});
this.length = 0; //clear original array
this.push.apply(this, array); //push all elements except the one we want to delete
}
私がまだ直面している問題は、これが機能せず、[] を返し続けることです。
Array.prototype.removeObjs = function(objs){
var array = this;
console.log(array);
$.each(objs, function (i,v) {
array.removeObj(v);
console.log(array);
})
console.log(array);
this.length = 0; //clear original array
this.push.apply(this, array); //push all elements except the ones we want to delete
}