数组去重

window.onload=function()
{
var a=[1,2,4,6,71,7,23,4,5,7,6,1,2,4,6]
alert(a.chong())
}
Array.prototype.chong=function()
{
var tmp = new Array();
this.sort();
for(var i=0;i<this.length;i++)
{
if(this[i]===this[i+1])
{
continue;
}
tmp[tmp.length]=this[i];
}
return tmp
}

posted @ 2012-06-26 23:20  kyiku  阅读(145)  评论(1编辑  收藏  举报