let rId=2; let list=[{id: 1,name:'a'}、{id:name3360'd'}、{id:name3360'c'}、{id:'c'} i list.length; I ) if(rid==list[I].id ) list.splice(I,1 ); 布雷克; 如果存在多个等于//2的id值,则返回break}}console.log(list );
let rId=2; let list=[{id: 1,name:'a'}、{id:name3360'd'}、{id:name3360'c'}、{id:'c'} i list.length; I () if ) list[I].idrid ) ) list.splice(I,1 ); I----; //数组本身变了,长度变了,数组元素进了一步,循环也进了一步}}console.log(list ); //或for(letI=list.length-1; i=0; I--}{if(list[I].idrid ) list.splice(I,1 ); } console.log (列表;