js map使用

//定义
array.map(function(item,index,arr), thisValue)

item 为当前元素 必填, index是当前元素索引值,选填,arr是当前元素所属数组,thisValue可选。对象作为该执行回调时使用,传递给函数,用作 "this" 的值。
如果省略了 thisValue,或者传入 null、undefined,那么回调函数的 this 为全局对象;

map不该变数组而是返回一个新数组

map() 不会对空数组进行检测

猜你喜欢

转载自www.cnblogs.com/ccqqcc/p/11116728.html