/ Published in: JavaScript
![](/img/icon_sav.png?v3)
Use this to step through an Array and keep only values the first instance of any values, removing all subsequent duplicates.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
Array.prototype.myUnique = function(){ var r = new Array(); o:for(var i = 0; i < this.length; i++) { for(var x = 0; x < r.length; x++) { if(r[x]==this[i]) { continue o; } } r[r.length] = this[i]; } return r; }; //usage yourArray = yourArray.myUnique();
Comments
![RSS Feed for Comments RSS Icon](/images/rss.png?v3)