There is a set of JSON data:
var tempJSON = [{id:1,Name:"peter"},{id:2,Name:"James"},{id:3,Name:"Other"}];
when passing in ids The value of [1,2] is how JS deletes the data with id 1,2 in the tempJSON array, and the final result is:
tempJSON=[{id:3,Name:"Other"}]
The workaround is as follows:
var
tempJSON = [{id:1,Name:
"peter"
},{id:2,Name:
"James"
},{id:3,Name:
"Other"
}];
var
newArr =
new
Array();
for
(
var
i=0;i< tempJSON.length;i++){
var
j=tempJSON[i];
if
(j.id!=1&&j.id!=2){
newArr.push(j);
}
}
console.info(newArr);