Skip to content

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 8 commits into from
Oct 29, 2019
Merged

WeakMap and WeakSet #67

merged 8 commits into from
Oct 29, 2019

Conversation

ArvinH
Copy link
Contributor

@ArvinH ArvinH commented Oct 20, 2019

Target chapter

1-js/05-data-types/08-weakmap-weakset

Modified files

File name Change(reason)
article.md 翻譯繁體中文
01-recipients-read/* 翻譯繁體中文
02-recipients-when-read/* 翻譯繁體中文

@javascript-translate-bot

Please make the requested changes. After it, add a comment "/done".
Then I'll ask for a new review 👻

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` 的鍵得來的資訊。
Copy link
Contributor Author

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` 的鍵得來的資訊,一起從記憶體中被移除

ArvinH and others added 2 commits October 21, 2019 18:15
Co-Authored-By: Len Chen <lenchen1112@users.noreply.github.com>
Co-Authored-By: Len Chen <lenchen1112@users.noreply.github.com>
@ArvinH ArvinH merged commit 8404726 into javascript-tutorial:master Oct 29, 2019
@javascript-translate-bot

Thank you 💖 I updated the Progress Issue #1 🎉 🎉 🎉

@ArvinH ArvinH deleted the 1-05-08 branch October 29, 2019 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants