The rest of this chapter will focus on new data structures added in ECMAScript. To some extent, they can be simulated in ES5. However, native support and explicit naming make code that utilizes these features more efficient and clearer.
In this recipe, we'll take a look at the basics of adding and removing entries from a Map
using the set
and delete
methods.
This recipe assumes that you already have a workspace that allows you to create and run ES modules in your browser. If you don't, refer to the first two chapters.
- Open your command-line application and navigate to your workspace.
- Create a new folder named
11-04-set-and-delete-from-map
. - Create a
main.js
file that defines a newclass
namedRocket
that takes a constructor argumentname
and assigns it to an instance property:
// main.js class Rocket { constructor(name) { this.name = name; } }
- Create an enum of different launch sites:
// main.js const LaunchSite ...