Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

callback without duplicates javascript

function myFunction(myArray, callBack){

 var unique = myArray.filter(function(item, pos) {
   //validates whether the first occurrence of current item in array
   // equals the current position of the item (only return those items) 
   return myArray.indexOf(item) == pos;
 });

 //wrap your result and pass to callBack function 
 callBack(unique);

}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #callback #duplicates #javascript
ADD COMMENT
Topic
Name
6+8 =