- Open your command-line application, and navigate to your workspace.
- Create a new folder named 12-03-add-remove-from-weak-set.
- Copy or create an index.html that loads and runs a main function from main.js.
- Create a main.js file that defines a new class named Rocket that takes a constructor argument name and assigns it to an instance property:
// main.js class Rocket { constructor(name) { this.name = name; } }
- Create a main function with some Rocket instances and a WeakMap instance. Add and remove the instances from the set:
// main.js export function main() {const saturnV = new Rocket('US: Saturn V');const falconHeavy = new Rocket('US: Falcon Heavy');const rocketSet = new WeakSet();rocketSet.add(saturnV);rocketSet.add(saturnV); ...