How it works...

The map works similarly to several of the other methods we've seen so far. It takes a function that receives an array element as a parameter and returns some value. Those values are collected into a new array, and that new array is returned by the map method.

Get ECMAScript Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.