JavaScript map() Method
The map() function executes a specified function for each item in an array.
The following example shows, how to square each value in an array using a map Method.
Example
var a=[1,2,3,4,5,6] function square(x){ return Math.pow(x,2); } //call 'square' function for each item in a using map var b=a.map(square); document.querySelector("#out").innerHTML=b;Try it Yourself