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

Array.push()

You can set the value of the length property to change the size of an array. If you set length to be smaller than its previous value, the array is truncated, and elements at the end are lost. If you set length to be larger than its previous value, the array becomes bigger, and the new elements added at the end of the array have the undefined value.


Array.map() ECMAScript 5

compute new array elements from old

Synopsis

array.map(f) array.map(f, o)

Arguments

f The function to invoke for each element of array. Its return values become elements of the returned array.

o An optional value on which f is invoked.

Returns

A new array with elements computed by the function f.

Description

map() creates a new array with the same length as array, and computes the elements of this new array by passing the elements of arrayto the function f. map()loops through the indexes of array, in ascending order, and invokes fonce for each element. For an index i, fis invoked with three arguments, and its return value is stored at index i of the newly created array:

a[i] = f(array[i], i, array)

Once map() has passed each element of array to f and has stored the results in the new array, it returns that new array.

See Array.forEach() for further details.

Array.push()

Example

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

See Also

Array.every() , Array.filter() , Array.forEach() , Array.indexOf() , Array.reduce()

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