Remove Duplicates from an array

Var ouputarray = inputarray .filter( function( item, index, inputArray ) {
           return inputArray.indexOf(item) == index;
});

Examples : 
var inputarray = ["apple", "bannana", "orange", "apple", "orange"];
ouputarray : ["apple", "bannana", "orange"]
var inputarray = ["12", "13", "14", "13", "12"];
ouputarray : ["12", "13", "14"]

Leave a comment

Your email address will not be published. Required fields are marked *