Home>Article>Web Front-end> What is the use of javascript map method?
In JavaScript, the map() method is used to return a new array. The elements in the array are the values of the original array elements after calling the function. The map() method will process the elements in sequence according to the order of the original array elements. Syntax "array.map(function(value, index value, array){})".
The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.
javascript map() method
map() method returns a new array, and the elements in the array are the values of the original array elements after calling the function.
The map() method processes elements sequentially in the order of the original array elements.
Note: map() will not detect empty arrays. map() does not change the original array.
Grammar:
array.map(function(item,index,arr){})
map is an array method with one parameter, the parameter is a function, and there are 3 parameters in the function
Rendering:点击按钮获取数组元素的平方根。
javascript advanced tutorial]
The above is the detailed content of What is the use of javascript map method?. For more information, please follow other related articles on the PHP Chinese website!