Skip to content

Commit 5aebb89

Browse files
authored
Fix typos in 1.5.8 (WeakMap and WeakSet)
1 parent e1a3f63 commit 5aebb89

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

1-js/05-data-types/08-weakmap-weakset/article.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ alert(cache.size); // 1 (Ouch! The object is still in cache, taking memory!)
207207

208208
For multiple calls of `process(obj)` with the same object, it only calculates the result the first time, and then just takes it from `cache`. The downside is that we need to clean `cache` when the object is not needed any more.
209209

210-
If we replace `Map` with `WeakMap`, then this problem disappears. The cached result will be removed from memory automatically after the object gets garbage collected .
210+
If we replace `Map` with `WeakMap`, then this problem disappears. The cached result will be removed from memory automatically after the object gets garbage collected.
211211

212212
```js run
213213
// 📁 cache.js
@@ -284,7 +284,8 @@ The most notable limitation of `WeakMap` and `WeakSet` is the absence of iterati
284284

285285
`WeakSet` is `Set`-like collection that stores only objects and removes them once they become inaccessible by other means.
286286

287-
It's main advantages are that they have weak reference to objects, so they can easily be removed by garbage colector.
288-
That comes at the cost of not having support for `clear`, `size`, `keys`, `values` ...
287+
Their main advantages are that they have weak reference to objects, so they can easily be removed by garbage colector.
288+
289+
That comes at the cost of not having support for `clear`, `size`, `keys`, `values`...
289290

290291
`WeakMap` and `WeakSet` are used as "secondary" data structures in addition to the "primary" object storage. Once the object is removed from the primary storage, if it is only found as the key of `WeakMap` or in a `WeakSet`, it will be cleaned up automatically.

0 commit comments

Comments
 (0)