This article is mainly to the JS array to weight and weight of the sample code is introduced, need friends can come to the reference, I hope to help you.
Method one: To repeat the data code as follows: <script> array.prototype.distinct=function () {var a=[],b=[]; for (Var prop in this) { va R d = This[prop]; if (D===a[prop]) continue; Prevent loops to prototype &NBSP;IF (b[d]!=1) { A.push (d); b[d]=1; } return A; var x=[' A ', ' B ', ' C ', ' d ', ' B ', ' A ', ' e ', ' A ', ' B ', ' C ', ' d ', ' B ', ' A ', ' e '; document.write (' original array: ' +x '); document.write ("<br/>"); document.write (' To repeat: ' +x.distinct ()); </script> Method Two: Take the duplicate data code as follows: <script type= "Text/javascript" > Array.prototype.distinct=function () { var a=[],b=[],c=[],d=[]; for (Var prop in this) { var d = This[prop] if (D===a[prop]) {  ; Continue; }//prevent loops to prototype if (b[d]!=1) { a.push (d); b[d]=1; &NB Sp } else { c.push (d); d[d]=1; } &NBSP} //return A; return C.distinct1 (); } array.prototype.distinct1=function () {var a=[],b=[]; for (Var prop in this) { var d = this[prop]; &NBS P;if (D===a[prop]) continue; Prevent loops to prototype &NBSP;IF (b[d]!=1) { A.push (d); b[d]=1; } return A; var x=[' A ', ' B ', ' C ', ' d ', ' B ', ' A ', ' e ', ' A ', ' B ', ' C ', ' d ', ' B ', ' A ', ' e ', ' f ', ' f ', ' G '; document.write (' original array: ' +x '); document.write ("<br/>"); document.write (' To repeat: ' +x.distinct ()); </script>