Loading topic
Map, Set, WeakMap, and WeakSet. This chapter explains the problems they solve and ho2 min readfor...of loops, and the difference between primitive values and object references.2 min readfor...of loops, and the difference between primitive values and object references. It also builds on the Map chapter, because a Set uses a very similar API.2 min readset, get, has, and delete. It also assumes you know for...of loops, array destructuring, and the spread operator.2 min readadd, has, delete, and size. It also assumes you are comfortable with for...of loops, the spread operator, and arrow functions. Here you will learn the order in which a Set gives back its values, the iteration methods it shares with 2 min readset, get, has, and delete. It also assumes you have used plain objects as lookup tables. Both structures store key-value pairs, but they behave differently in ways that cause real bugs. The goal here is to recognize those differences2 min readObject.entries, and JSON.stringify. Map and Set are built for fast lookups. Most other APIs expect arrays, plain objects, or JSON strings, so you will often convert betwe2 min readfor...of, and know that Map keys are compared with SameValueZero. It also assumes you are comfortable with arrow functions and arrays of objects.2 min readMap and Set from earlier chapters. Weak collections only make sense once you know how JavaScript decides when an object's memory can be freed, so this chapter covers that first.2 min readset, get, has, delete) and that WeakMap keys must be objects held weakly. It also assumes you are comfortable with ES classes. The focus here is on two patterns where a WeakMap is the right tool: caching computed result2 min readsize and no iteration. It also assumes you know what reachability means for garbage collection.2 min readWeakRef and FinalizationRegistry, and how they differ from weak collections.2 min read