merge array and remove duplicate javascript using es6 code example
Example 1: 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));
Example 2: remove duplicate array es6
let a = [10,20,30,10,30];
let b = [... new Set(a)];
console.log(b);