Posted By

guilhermehn on 08/23/12


Tagged

javascript array remove duplicate


Versions (?)

Remove duplicate itens from an array


 / Published in: JavaScript
 

Original by dvdrtrgn

  1. function unique(arr, dup) {
  2. dup = dup ? arr.concat() : arr;
  3. for(var i = 0; i < dup.length; i++) if(dup.indexOf(dup[i]) < i) dup.splice(i--);
  4. return dup;
  5. }

Report this snippet  

You need to login to post a comment.