JS数组几个参数雷同的方法

// 箭头函数

methodName((element) => { /* … */ } )
methodName((element, index) => { /* … */ } )
methodName((element, index, array) => { /* … */ } )

// 回调函数
methodName(callbackFn)
methodName(callbackFn, thisArg)

// 内联回调函数
methodName(function(element) { /* … */ })
methodName(function(element, index) { /* … */ })
methodName(function(element, index, array){ /* … */ })
methodName(function(element, index, array) { /* … */ }, thisArg)

map()

概述:创建一个新数组,这个新数组由原数组中的每个元素都调用一次提供的函数后的返回值组成

返回值:一个新数组,每个元素都是回调函数的返回值。

 

filter()

使用回调函数过滤原数组,将符合条件的元素添加到一个新数组并返回这个新数组

find()  
findIndex()   
findLastIndex()   
flatMap()  
forEach()  
group()  
groupToMap()  
some()  
every()  

posted on 2022-09-15 15:58  前端码牛  阅读(31)  评论(0编辑  收藏  举报

导航