Creating a Map from the existing data

We just saw how to add values individually to maps. This can be tedious, however. For example, if we are working with a dataset that might be very large or unknown ahead of time, it would be nice to initialize a map with a function call rather than hundreds or thousands.

In this recipe, we'll take a look at how to create a new Map with the preexisting data.

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.