let list = [1,2,3,4,5,6,3]
let list2 = list.map((el)=>{return el=el+1}) //map 解决每个元素,并把返回的值组成新数组
console.log(" list2 ", list2 ) //list2 (6) [2, 3, 4, 5, 6, 7]
let list3 = list.filter((el)=>{return el>3}) //filter 返回符合判断的元素组成数组
console.log(" list3 ", list3 )//list3 (3) [4, 5, 6]
let list4 = list.some((el)=>{return el>3}) // some 判断元素能否符合判断,只有有一个符合就返回 true
console.log(" list4 ", list4 )//list4 true
let list5 = list.every((el)=>{return el>3}) // every 判断元素能否一律符合判断
console.log(" list5 ", list5 )//list5 false
let list6 = Array.isArray(list ) // every 判断元素能否是数组
console.log(" list6 ", list6 )// list6 true
let list7 = list.indexOf(13) // 找数组中能否存在该元素,有则返回该元素的下角标,否则返回-1
console.log(" list7 ", list7 )// list7 2
let list8 = list.lastIndexOf( 2,13) // 找数组中能否存在(符合条件的元素),只有有一个符合则返回该元素的下角标,否则返回-1
console.log(" list8 ", list8 )// list8 1
list.splice( 2,0,9) // splice():删除、插入和替换。使用 splice(起始位置、 0(要删除的项数)和要插入的项)。会改变原数据
console.log(" list ", list)// list [1, 2, 9, 3, 4, 5, 6, 3]
let list9 = list.slice( 2,8) // slice(): 根据下角标截取数据,不会改变原数据
console.log(" list9 ", list9 , list)// list [1, 2, 9, 3, 4, 5, 6, 3]
// sort() 排序
// reverse():反转数组项的顺序
// concat() :合并数组
// shift():删除原数组第一项,并返回删除元素的值;假如数组为空则返回undefined 。
// unshift:将参数增加到原数组开头,并返回数组的长度 。
//push(): 把里面的内容增加到数组末尾,并返回修改后的长度。
//pop():移除数组最后一项,返回移除的那个值,减少数组的length。
//join,就是把数组转换成字符串,而后给他规定个连接字符,默认的是逗号( ,)