TS (ES6)
使用Set进行去重
let i=[1,2,3];
const b=[2,3,4];
i=i.concat(b);
const result=Array.from(new Set(i));
//result => [1,2,3,4]
Array.prototype.uniq = function () {
return Array.from(new Set(this))
}
[1, 2, 3, 3, 5,4].uniq()
Java
List a;//[1,2,3]
List b;//[2,4,5]
a.addAll(b);
List result=a.stream().distinct().collect(Collectors.toList());
//result => [1,2,3,4,5]