Method 1: Remove duplicate data
<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; //Prevent looping to 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('Original array:' x);<br>document.write("<br />");<br>document.write('After deduplication:' x.distinct());<br></script>
Method 2: Get duplicate data