map()
- 语法:array.map(function(currentValue, index, arr), thisValue)
- 参数说明
- map()对每个元素依次调用函数进行处理,并返回一个处理过的元素值组成的新数组。
- map()不会改变原数组。
reduce()
- 语法:array.reduce(fuction(total, currentValue, currnetIndex, arr), initialValue)
- 参数
- reduce()接受一个函数作为累加器,数组中的每个值从左到右计算,最终返回一个值。
filter()
- 语法:array.filter(function(currentValue, index, arr), thisValue)
- 参数
- filter()创建一个新的数组,里面元素是通过筛选的所有元素。
- function()返回值应该为boolean类型,filter()筛选出结果为true的元素。