Tag: array.map

Web Tricks

4 Uses of JavaScript’s Array.map() You Should Know

From the classic forloop to the forEach() method, various techniques and methods used to iterate through datasets abound JavaScript. However, one of the more popular methods is the .map() method. .map() creates an array from calling a specific function on each item in the parent array. .map() is a non-mutating method in that it creates a new array as against mutating methods which only make changes to the calling array. This can be tricky to remember. In this post, we'll look at 4 noteworthy uses of the .map() in JavaScript. Let's begin!   Calling a Function on Each Item in an Array .map() as earlier stated accepts a callback function as one of its arguments and an important parameter of that function is the current value of the item being processed by the function. This is...