concat
The combined array
filter
processing array
indexOf
for the first time the position of
lastIndexOf
last occurrence position
If there are identical elements, inclusive return different positions (return
false
)
if only one element, the same position and last position (returntrue
)
let a = [1,3,4], b = [2,3,4];
let c = a.concat(b).filter((cur, i, arr) => {
return arr.indexOf(cur) ==== arr.lastIndexOf(cur);
}); // c = [1,2]