How to do it...

  1. Open your command-line application, and navigate to your workspace.
  2. Create a new folder named 12-01-add-remove-from-set.
  3. Copy or create an index.html that loads and runs a main function from main.js.
  4. Create a main.js file that defines a main function. In that function, create a new Set instance, then add and remove a few items from it:
// main.jsexport function main() {    const rocketSet = new Set();    rocketSet.add('US: Saturn V');    rocketSet.add('US: Saturn V');    rocketSet.add('US: Falcon Heavy');    console.log(rocketSet);    rocketSet.delete('US: Falcon Heavy');    console.log(rocketSet);}
  1. Start your Python web server, and open the following URL in your browser: http://localhost:8000/.
  1. You will see the following output:

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.