标签:else key for [] push math turn ret array
var array=[]
var obj={}
var len=array/2
var lastlen=0;
var key=[];
for(var i=0;i<array.legth;i++){
if(obj[array[i]]){
obj[array[i]]++;
}else{
obj[array[i]]=1;
}
if(obj[array[i]]>lastlen){
key=[];
key.push(array[i]);
lastlen=obj[array[i]];
}else if(obj[array[i]]=lastlen){
key.push(array[i]);
}
len=Math.floor((len-i)/2);
if(lastlen>len){
return;
}
}
console.log(key);
标签:else key for [] push math turn ret array
原文地址:http://www.cnblogs.com/kissjs/p/6536145.html