How it works...

As said before, the map is a pairing between a key and value. The Map constructor expects an iterable collection of key-value pairs. In the preceding recipe, we've passed a two-dimensional array. The outer dimension is the iterable that contains multiple entries.

The inner dimension is the key-value pair. The first member of the key-value is the launch site. The second member is the value (in our case, a Rocket). The Map constructor iterates over the entries provided and creates a pairing between each.

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.