JavaScript: The Definitive Guide, Sixth Editio javaScript权威指南(第6版) pdf 文字版-文字版, javascript电子书, 和javascript 有关的电子书:

7.9.2 map()

7.9.2 map()


The map()method passes each element of the array on which it is invoked to the function you specify, and returns an array containing the values returned by that function. For example:

a = [1, 2, 3]; b = a.map(function(x) { return x*x; }); // b is [1, 4, 9]

The function you pass to map() is invoked in the same way as a function passed to forEach(). For the map()method, however, the function you pass should return a value. Note that map() returns a new array: it does not modify the array it is invoked on. If that array is sparse, the returned array will be sparse in the same way: it will have the same length and the same missing elements.

欢迎转载,转载请注明来自一手册:http://yishouce.com/book/1/31357.html
友情链接It题库(ittiku.com)| 版权归yishouce.com所有| 友链等可联系 admin#yishouce.com|粤ICP备16001685号-1