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
- new Map, set, get, has and delete
- keys, values, entries and forEach
- Map.groupBy (ES2024)
- How a Map compares keys: SameValueZero
- Set: add, has, delete and size
- union, intersection and difference (ES2025)
- WeakMap and WeakSet
- The iterator protocol: next, done and value
- Symbol.iterator on your own class
- function* and yield
- next(value), return and yield*
- Async generators and for await
- Writing a regex: literals and new RegExp
- Character classes and quantifiers
- Anchors and flags
- Groups and named groups
- test, exec, match and matchAll
- replace with a function, and split
- Lookahead and lookbehind
- Which collection