by Sai gowtham

How use map method in JavaScript

Home » javascript » How use map method in JavaScript

In es6 we got most useful array methods in JavaScript one of them is method in this tutorial we will learn about how to use the map method.

The map method takes the callback function as an argument and runs on each element present in the array, at final it returns the new array with the updated values.

map method doesn’t mutate/change the original array.


function doubleNumbers(arr){

    return => num*2 )


console.log(doubleNumbers([1,2,3,4,5])) // [2,4,6,8,10]

The callback function inside the map method takes three parameters currentvalue , index , array.

function convertIntegers(arr){

    return> Number(num) );



//output   [1, 2, 3, 4]