Map Function In JavaScript

Jagadhiswaran D
2 min readOct 31, 2021

Map Function In JavaScript:

Map Function Calls a Callback Function For Each element In a Array And Constructs a new Array. The Below Example explains the map function clearly At first array is declared we need to solve the Array for different solutions but the array value is same . To get different solutions for same array we use map functions that we map the functions to array according to the problem. Here I have taken four examples

Example 1:

I have made a function to the logic to double the number and i have given function name and given the return value multiplied by 2 and console.log the output gives the exact expected output.

Example 2:

I have made a function to make the array give the cube of the value . I have written a function that returns the cube with the logic multiplying it three times.

Example 3:

I have made a function to make the values give the hexadecimal value of the array . I have written a function with To string which converts the Array to the hexadecimal

Example 4:

In this Function I have used a Higher order function to map the Value And there is also another method as arrow Function to map the array and in this function I have used the square to get the square of the array

the Map function is used to give many function to a single value by mapping the function to the value

for eg: there is a car and car has many functions to do like Moving , Horn and Acceleration All this functions are mapped to the car.

Program
Expected Output
Output

--

--

Jagadhiswaran D

Front-end Developer | JavaScript Developer | Web Developer | Software Engineer | Blockchain Ethusiast | Web3.js | Ethereum |