Remove duplicate itens from an array


/ Published in: JavaScript
Save to your folder(s)

Original by dvdrtrgn


Copy this code and paste it in your HTML
  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.