Answers for "react javascript combine two arrays and remove duplicates"

7

javascript remove duplicate in two arrays

array1 = array1.filter(function(val) {
  return array2.indexOf(val) == -1;
});
// Or, with the availability of ES6:

array1 = array1.filter(val => !array2.includes(val));
Posted by: Guest on April-27-2020
0

javascript array filter duplicates in react

const uniqueNames = names.filter((val,id,array) => array.indexOf(val) == id);
Posted by: Guest on December-22-2021

Code answers related to "react javascript combine two arrays and remove duplicates"

Code answers related to "Javascript"

Browse Popular Code Answers by Language