What is Map and How to Implement Your Own Map Method in Javascript

Photo by Capturing the human heart. on Unsplash

You are probably thinking about the world map when you are looking into this picture.

Except today…we are talking about the map function in relationship.

What is the map function?

In javascript, the map function provides a convenient way to apply some function to every single element in an array.

For example, I can use a map function to multiply each element for a factor of 2:

let arr = [1,2,3]
	arr = arr.map(ele => ele * 2);
	console.log(arr);//[2,4,6]

#web-development #es6 #frontend #es5 #javascript #programming

What is map & how to implement your own map method in JavaScript
1.35 GEEK