JavaScript Map Function ❗❗❗

Ankan Das
2 min readMay 21, 2021

Sometimes you may need to take an array and apply some procedure to its elements so that you get a new array with modified elements. Instead of manually iterating over the array using a loop, you can simply use the built-in Array.map() method. The Array.map() method allows you to iterate over an array and modify its elements using a callback function. The callback function will then be executed on each of the array's elements.

For example, suppose you have the following array doing some basic operation over the elements.

Iterate over an array using for loop

But you can actually use the Array.map() method to achieve the same result. Here's an example:

Iterate over an array using map() method

The Array.map() method is commonly used to apply some changes to the elements, whether multiplying by a specific number as in the code above, or doing any other operations that you might require for your application.

Thanks a lot for reading till end. You can contact me in case if you need any help.👍👍👍👍👍👍

Web: https://ankandas.netlify.app/
Instagram:
https://www.instagram.com/ankan_designer/
Github:
https://github.com/Ankan982
All Links:
abhisheksrivastavabbn@gmail.com

--

--

Ankan Das

Software Developer who loves to explore new technologies. To know more about me lets connect : https://ankandaslinks.netlify.app/