方法 1: 重複データを削除します
<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 //プロトタイプ<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>
方法 2: 重複データを取得する