Answers for "merge 2 array without duplicates in js"

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
1

javascript merge two lists without duplicates

const array1 = ['a','b','c'];
const array2 = ['c','c','d','e'];
const array3 = [...new Set([...array1,...array2])];
console.log(array3); // ["a", "b", "c", "d", "e"]
Posted by: Guest on November-23-2021

Code answers related to "merge 2 array without duplicates in js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language