Posted By

keith on 12/11/09


Tagged

javascript


Versions (?)

Remove Duplicate Numbers in an Array


 / Published in: JavaScript
 

from this page: http://dreaminginjavascript.wordpress.com/2008/08/22/eliminating-duplicates/

  1. var arr=[9, 7, 1, 9, 2, 3, 7, 4, 5, 4,7],
  2. i,
  3. arrayLength=arr.length,
  4. out=[],
  5. obj=[];
  6.  
  7. for (i=0; i < arrayLength; i++) {
  8. obj[arr[i]]=0;
  9. }
  10.  
  11. for (i in obj) {
  12. out.push(i);
  13. }
  14.  
  15. alert(out);

Report this snippet  

You need to login to post a comment.