js for循环删除两个数组相同元素

 1  var id = ['a','b','c','a','d','a','a','b','d','c','a','b','c','a','b','c']
 2   var del = ['a','c'];
 3   var temp01 = [];
 4   var temp02 = [];
 5 
 6   for(var i in del){
 7     temp01[del[i]] = true;
 8   }
 9 
10   for (var k in id){
11     if(!temp01[id[k]]){
12           temp02.push(id[k])
13       }
14   }
15 
16   console.log(temp02);

 

posted on 2017-10-14 18:04  骑士007  阅读(2853)  评论(0编辑  收藏  举报

导航