Learn JavaScript

Lesson 2 of 9 · Map, Set, WeakMap, Iterators, Generators and Regular Expressions

Module 16 · Map, Set, WeakMap, Iterators, Generators and Regular Expressions

Every Method: Map, Set, WeakMap, Iterators, Generators and the Regex Language, One by One

ProReading

Lesson 01 showed each tool doing one job. This lesson is the reference you come back to. Each section takes one method or one rule and runs a small program. It ends with a one-row table: what it returns, whether it changes anything, and its cost.

Checking what this lesson needs for you…

What is inside Every Method: Map, Set, WeakMap, Iterators, Generators and the Regex Language, One by One

  1. new Map, set, get, has and delete
  2. keys, values, entries and forEach
  3. Map.groupBy (ES2024)
  4. How a Map compares keys: SameValueZero
  5. Set: add, has, delete and size
  6. union, intersection and difference (ES2025)
  7. WeakMap and WeakSet
  8. The iterator protocol: next, done and value
  9. Symbol.iterator on your own class
  10. function* and yield
  11. next(value), return and yield*
  12. Async generators and for await
  13. Writing a regex: literals and new RegExp
  14. Character classes and quantifiers
  15. Anchors and flags
  16. Groups and named groups
  17. test, exec, match and matchAll
  18. replace with a function, and split
  19. Lookahead and lookbehind
  20. Which collection