/ Published in: JavaScript
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
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
Subscribe to comments
You need to login to post a comment.

This is excellent! Shortest variation I've seen.
This is excellent! Shortest variation I've seen.
This is excellent! Shortest variation I've seen.
This is excellent! Shortest variation I've seen.