Delete Duplicate values in array using Javascript

by satheeshkumar 2014-08-30 17:25:13

Delete Duplicate values in array using Javascript,
 
<script>
var str1=[5,6,5,6,8,9,7,8,9];
  var arr = str1.split(',');	
  var i,
      len=arr.length,
      out=[],
      obj={};
 
  for (i=0;i<len;i++)
  {
    obj[arr[i]]=0;
  }
  for (i in obj) 
 {
    out.push(i);
  }
  alert(out);
</script>
Output:
5,6,8,9,7

The above function eliminates duplicate numbers in the array.
1511
like
0
dislike
0
mail
flag

You must LOGIN to add comments