// 一种数组去重
union(arr = []) {
return arr.reduce((res, item) => (res.indexOf(item) !== -1 ? res : res.concat(item)), []);
}
The first method is to reduce a parameter callback, the second parameter is the starting value res.
Callback function the first parameter is a result of the execution, the second argument is that each element of the array