Posted By

nate63179 on 03/23/10


Tagged


Versions (?)

JS: Uniquify an array


 / Published in: JavaScript
 

  1. Array.prototype.unique = function () {
  2. var r = new Array();
  3. o:for(var i = 0, n = this.length; i < n; i++)
  4. {
  5. for(var x = 0, y = r.length; x < y; x++)
  6. {
  7. if(r[x]==this[i])
  8. {
  9. continue o;
  10. }
  11. }
  12. r[r.length] = this[i];
  13. }
  14. return r;
  15. }

Report this snippet  

You need to login to post a comment.