Posted By

guilhermehn on 08/23/12

Tagged

javascript array

Viewed 5 times

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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.