JavaScript 数组函数 map()

JavaScript 数组函数 map() 学习心得

map()函数是一个数组函数;

它对数组每个原素进行操作,不对空数组进行操作;

不改变原本的数组,返回新数组;

arr.map(function(item,index,arr){

},thisValue);

item是必须的,其他不是必须的,函数中return不是必须的,会自动返回item

thisValue是可选的,对象作为该执行回调时使用,传递给函数,用作 "this" 的值。
如果省略了 thisValue,或者传入 null、undefined,那么回调函数的 this 为全局对象。

猜你喜欢

转载自www.cnblogs.com/158cm/p/11375145.html