Array.prototype.show=function(){
let _this=this;
let arrs=[];
_this.forEach((val,index)=>{
let net=_this.indexOf(val,index+1)
if(net==-1){
arrs.push(val)
}
})
return arrs
}
let arr1=['北京','上海','北京','北京','上海','深圳','深圳','北京','北京','上海','深圳','北京','北京']
let arr2=arr1.show()
let arr3=[];
for(let i=0;i<arr2.length;i++){
let arr4=arr1.filter((val,index)=>{
return val==arr2[i]
})
let arr5=arr4.length
arr3.push(arr5);
}
Math.max.apply(null,arr3)
7
arr2[arr3.indexOf(Math.max.apply(null,arr3))]
"北京"