ES6中数组的includes方法

includes()

该方法可以用检测数组中是否包含某个值

const testArray = [1,2,3,4,5]
console.log(testArray.includes(1))

输出

true

该方法可接收第二个参数作为搜索的起始位置

const testArray = [ 1 , 2 , 3 , 4 , 5 ]
console.log(testArray.includes(1,2))

输出

false

数组去重可以将数组转化为ES6中的set数据类型

posted @ 2020-02-28 10:05  卑微小吴  阅读(8328)  评论(0)    收藏  举报