Skip to content

Commit

Permalink
Merge pull request #1292 from Violet-Bora-Lee/patch-26
Browse files Browse the repository at this point in the history
minor
  • Loading branch information
iliakan authored Aug 30, 2019
2 parents 4ed5a0d + 6fc41ba commit b0d39f8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions 1-js/05-data-types/08-weakmap-weakset/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ We can avoid it by switching to `WeakMap` instead:

```js
// 📁 visitsCount.js
let visitsCountMap = new WeakMap(); // map: user => visits count
let visitsCountMap = new WeakMap(); // weakmap: user => visits count

// increase the visits count
function countUser(user) {
Expand All @@ -164,7 +164,7 @@ function countUser(user) {
}
```

Now we don't have to clean `visitsCountMap`. After `john` object becomes unreachable by all means except as a key of `WeakMap`, it gets removed from memory, along with the information by that key from `WeakMap`.
Now we don't have to clean `visitsCountMap`. After `john` object becomes unreachable by all means except as a key of `WeakMap`, it gets removed from memory, along with the information by that key from `WeakMap`.

## Use case: caching

Expand Down

0 comments on commit b0d39f8

Please sign in to comment.