Skip to content

Commit aa36757

Browse files
authored
Merge pull request #589 from pedrofgsrj/patch-1
Fix method name and other minor changes
2 parents 1ee1176 + f62cd55 commit aa36757

File tree

1 file changed

+3
-3
lines changed
  • 1-js/05-data-types/07-map-set-weakmap-weakset

1 file changed

+3
-3
lines changed

1-js/05-data-types/07-map-set-weakmap-weakset/article.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ Now where do we need such thing?
324324
The idea of `WeakMap` is that we can store something for an object that exists only while the object exists. But we do not force the object to live by the mere fact that we store something for it.
325325
326326
```js
327-
weakMap.put(john, "secret documents");
327+
weakMap.set(john, "secret documents");
328328
// if john dies, secret documents will be destroyed
329329
```
330330
@@ -378,7 +378,7 @@ With a regular `Map`, cleaning up after a user has left becomes a tedious task:
378378
`WeakSet` behaves similarly:
379379
380380
- It is analogous to `Set`, but we may only add objects to `WeakSet` (not primitives).
381-
- An object exists in the set while it has reachable from somewhere else.
381+
- An object exists in the set while it is reachable from somewhere else.
382382
- Like `Set`, it supports `add`, `has` and `delete`, but not `size`, `keys()` and no iterations.
383383
384384
For instance, we can use it to keep track of whether an item is checked:
@@ -429,4 +429,4 @@ The most notable limitation of `WeakMap` and `WeakSet` is the absence of iterati
429429
430430
- Also does not support `size/clear()` and iterations.
431431
432-
`WeakMap` and `WeakSet` are used as "secondary" data structures in addition to the "main" object storage. Once the object is removed from the main storage, so it only stays in `WeakMap/WeakSet`, they clean up automatically.
432+
`WeakMap` and `WeakSet` are used as "secondary" data structures in addition to the "main" object storage. Once the object is removed from the main storage, if it is only found in the `WeakMap/WeakSet`, it will be cleaned up automatically.

0 commit comments

Comments
 (0)