1.数组去重
let arr = [1,2,3,4,5]
let arr1 = {...arr}
console.log(arr1)
3.字符串转Numer类型
let str = '123' //number
let num = +str
console.log(typeOf(num)) //Number
4.Number转字符串类型
let num = 123 //number
let str = num + ''
console.log(typeOf(str)) //String
5.合并两个对象
var a = {0:1}
var b = {1:2}
console.log(Object.assign(a,b)) //Object.assign()
console.log({...a,...b}) // {...a,...b}
6.数组扁平化
var arr = [1,2,[3,4,[5,6]]]
console.log(arr.flat(3)) //[1,2,3,4,5,6]
7.小数化为整数
console.log(~~6.66) // 6
console.log(6.66 >> 0) // 6
8.数组截取前几位
var arr = [1,2,3,4,5]
arr.length = 3
console.log(arr) //[1,2,3]
console.log(arr.slice(-1)[0]) //5