Learn JavaScript

Lesson 5 of 9 ¡ Map, Set, WeakMap, Iterators, Generators and Regular Expressions

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

Under the Hood: V8's Map, When a WeakMap Lets Go, Paused Generators and Regex Backtracking

ProReading

The first four lessons used these tools from the outside. This one opens them. You will see why a Map can promise both speed and order, and what "weak" really means to the garbage collector. You will see what a paused generator is in memory, and how one short regex can stop a server for minutes.

Checking what this lesson needs for youâ€Ļ

What is inside Under the Hood: V8's Map, When a WeakMap Lets Go, Paused Generators and Regex Backtracking

  1. How V8 keeps a Map: a hash table that remembers order
  2. What a WeakMap entry needs before it is freed
  3. A generator object is a paused frame
  4. What for-of does when you stop early
  5. Backtracking: how the regex engine searches
  6. Catastrophic backtracking, counted
  7. Writing patterns that cannot explode