js数组删除另一个数组存在的值

var selectStudentList=[{id:1,name:"张三"},{id:2,name:"李四"},{id:3,name:"王五"}];

var studentList=[{id:1,name:"张三", age:"12"}];
 
for(var i=0;i<studentList.length;i++){
    for(var j=0;j<selectStudentList.length;j++){
        if(selectStudentList[j].id==studentList[i].id){
            selectStudentList.splice(j,1);
            j--;
        }
    }
}
console.log(selectStudentList);
posted @ 2021-03-11 11:59  Jlov  阅读(528)  评论(0)    收藏  举报