js去重对象的属性值

var oldArr =[
                {name:"zhangs"},
                {name:"zhang"},
                {name:"zhanga"}
                {name:"zhang"}];
                var allArr=[];
                $.each.(olDArren,function(i,v){  
                         var flag=true;
                         if(allArr.length>0){
                                  $.each(allArr,function(n,m){
                                          if(allArr[n].name==oldArr[i].name){
                                                flag=false;
                                          }
                                          if(flag){
                                                allArr.push(oldArr[i])
                                          }
                                  })
                         }
                });
                console.log(allArr)

你可能感兴趣的:(js去重对象的属性值)