JS中的map

定义和用法:

map() 方法返回一个新数组,数组中的元素为原始数组元素调用函数处理后的值。

map() 方法按照原始数组元素顺序依次处理元素。

注意: map() 不会对空数组进行检测。

注意: map() 不会改变原始数组。

语法:

array.map(function(currentValue,index,arr), thisValue)

参数说明:

 

 

实例:

var nums=[10,20,30];
    nums.map(function(value,index,arr){
        document.write('value值为:'+value); //10 20 30
        document.write('index值为:'+index); //0 1 2
        document.write('arr值为:'+arr); //[10,20,30]
    })

 

1
array.map(function(currentValue,index,arr), thisValue)
posted @ 2019-11-01 14:37  Mica  阅读(398)  评论(0编辑  收藏  举报