方法一:去重复数据
<script><BR>Array.prototype.distinct=function(){<BR>var a=[],b=[];<BR>for(var prop in this){<BR> var d = this[prop];<BR> if (d===a[prop]) continue; //防止循环到prototype<BR> if (b[d]!=1){<BR> a.push(d);<BR> b[d]=1;<BR> }<BR>}<BR>return a;<BR>}<BR>var x=['a','b','c','d','b','a','e','a','b','c','d','b','a','e'];<BR>document.write('原始数组:'+x);<BR>document.write("<br />");<BR>document.write('去重复后:'+x.distinct());<BR></script>
方法二:取重复数据