解答一(推荐):
var s = [0,2,3,4,4,0,2];
for(var i=0,o={},tmp=[],count=0,l=s.length;i<l;i++){
if(o[s[i]]){
count++;
}else{
o[s[i]]=1;
tmp.push(s[i])
}
}
alert(count);
alert(tmp)
解答二:
Array.prototype.strip=function()
{
if(this.length<2) return [this[0]]||[];
var arr=[];
for(var i=0;i<this.length;i++)
{
arr.push(this......
阅读全文