-
Notifications
You must be signed in to change notification settings - Fork 22
WeakMap and WeakSet #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lenchen1112
requested changes
Oct 21, 2019
1-js/05-data-types/08-weakmap-weakset/01-recipients-read/task.md
Outdated
Show resolved
Hide resolved
1-js/05-data-types/08-weakmap-weakset/01-recipients-read/solution.md
Outdated
Show resolved
Hide resolved
1-js/05-data-types/08-weakmap-weakset/02-recipients-when-read/task.md
Outdated
Show resolved
Hide resolved
1-js/05-data-types/08-weakmap-weakset/02-recipients-when-read/task.md
Outdated
Show resolved
Hide resolved
1-js/05-data-types/08-weakmap-weakset/02-recipients-when-read/task.md
Outdated
Show resolved
Hide resolved
Please make the requested changes. After it, add a comment "/done". |
ArvinH
commented
Oct 21, 2019
function countUser(user) { | ||
let count = visitsCountMap.get(user) || 0; | ||
visitsCountMap.set(user, count + 1); | ||
} | ||
``` | ||
|
||
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`. | ||
現在我們不用清理 `visitsCountMap`。當 `john` 物件變得不可存取,只剩下作為 `WeakMap` 的鍵後,它會從記憶體中被移除,連同那些從 `WeakMap` 的鍵得來的資訊。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
變得
改成 變成
感覺順一些?
Suggested change
現在我們不用清理 `visitsCountMap`。當 `john` 物件變得不可存取,只剩下作為 `WeakMap` 的鍵後,它會從記憶體中被移除,連同那些從 `WeakMap` 的鍵得來的資訊。 | |
現在我們不用清理 `visitsCountMap` 了。當 `john` 物件變成除了作為 `WeakMap` 的鍵值以外,其餘皆不可達的情況時,它就會連同那些從 `WeakMap` 的鍵得來的資訊,一起從記憶體中被移除。 |
Co-Authored-By: Len Chen <lenchen1112@users.noreply.github.com>
Co-Authored-By: Len Chen <lenchen1112@users.noreply.github.com>
lenchen1112
approved these changes
Oct 21, 2019
ArvinH
commented
Oct 21, 2019
tom76kimo
approved these changes
Oct 28, 2019
Thank you 💖 I updated the Progress Issue #1 🎉 🎉 🎉 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Target chapter
1-js/05-data-types/08-weakmap-weakset
Modified files
article.md
01-recipients-read/*
02-recipients-when-read/*