- Open your command-line application, and navigate to your workspace.
- Create a new folder named 12-04-create-weak-set-from-data.
- 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 an array of rocket instances. Create a new WeakSet from the array. Try to add a string to WeakSet:
// main.js export function main() { const rockets = [ new Rocket('US: Saturn V'), new Rocket('US: Saturn V'), new Rocket('US: Saturn V'), new Rocket('USSR: Soyuz') , new Rocket('CN: Long March') ] const rocketSet = new WeakSet(rockets); console.log(rockets); }
- Start ...