2017  Kodetalk | Feedback | Privacy Policy | Terms | About
userimage

How to remove duplicate elements from an array using javascript

How to remove duplicate elements from an array using javascript. I want to make a best approach for doing this.

userimage

try below code to remove duplicates.

var arrayString = // Array elements that have duplicates
var resultArray = [];
$.each(arrayString, function(i, element){
   if($.inArray(element, resultArray) === -1) {
       resultArray.push(element);
   }
});
Answer is