数组合并去重
//封装一个方法用来做这个事情,javascript有自带Array.from(),方便快捷
function combine(){
let arr=[].concat.apply([],arguments);
return Array.from(new Set(arr));
}
//定义两数组,包含重复的数字
var m = [1, 2, 3], n = [2, 3, 3,4];
//调用方法,输出结果
console.log(combine(m, n));
//数组去重的用法
var var fruits = ["banana", "apple", "orange", "grape", "banana", "apple", "others"];
var uniqueFruits=Array.from(new Set(fruits));
console.log(uniqueFruits);