duplicates of 2 arrays javascript code example
Example 1: duplicate numbers in an array javascript
[1, 1, 2, 2, 3].filter((element, index, array) => array.indexOf(element) !== index) // [1, 2]
Example 2: compare two arrays and make sure there are no duplicates js
array1 = array1.filter(val => !array2.includes(val));