SOURCE

// 数组去重
let arr = [2,3,4,4,,2,7]
let newArr = [...new Set(arr)]
let newArr_ = Array.from(new Set(arr))
// console.log(newArr, newArr_)

// 数组去重合并
function combine () {
  let arr = [].concat.apply([], arguments)
  // let arr = [].slice.call(arguments)
  console.log('*****',arr)
  return Array.from(new Set(arr))
}
var m = [2,3,5]
var n = [3,5]
var l = [6]
console.log(combine(m,n,l))

// 自己去重
let newArr2 = arr.filter((value,index,arr) => {
  // console.log('---', index, value,  arr.indexOf(value))
  return index === arr.indexOf(value)
})

// console.log('newArr2', newArr2)

// 重复次数最多的元素
var arr1 = [1,2,3,4,3,2,2];
var arr_temp = {};
arr1.map( value => {
  if(arr_temp[value] !== undefined) {
    arr_temp[value] +=1
  } else {
    arr_temp[value] = 1
  }
})

let max_number = Math.max(...Object.values(arr_temp))

// console.log(Object.values(arr_temp), max_number)

// 计算数字之和
function get2num(arr, n) {
	let arr_temp = [];
	let hasNum = 0;
  
	// arr.map(value => arr_temp[value]=1);
  // console.log('-------', arr)
  arr.map( (value) => {
    
    arr_temp[value] = 1
    // console.log('22', value, arr_temp[value])
  })
  console.log(arr_temp, arr_temp.length)
  
	arr.map((value, index) => {
    // console.log('----', arr_temp[n-value], n-value)
		if(arr_temp[n-value] === 1 && value !== n-value){
			hasNum = 1;
			console.log('num ===', value, n-value);
		} 
	})
	if(!hasNum) {
		console.log('no such 2 num');
	}
}
get2num([1,9,6,8,4], 8) 

console 命令行工具 X clear

                    
>
console