Merge pull request #757 from GarciaPL/patch-1

Update article about WeakMap's delete function
This commit is contained in:
Ilya Kantor 2019-01-27 19:34:04 +03:00 committed by GitHub
commit 58b7d72120
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -328,7 +328,7 @@ Compare it with the regular `Map` example above. Now if `john` only exists as th
- `weakMap.get(key)` - `weakMap.get(key)`
- `weakMap.set(key, value)` - `weakMap.set(key, value)`
- `weakMap.delete(key, value)` - `weakMap.delete(key)`
- `weakMap.has(key)` - `weakMap.has(key)`
Why such a limitation? That's for technical reasons. If an object has lost all other references (like `john` in the code above), then it is to be garbage-collected automatically. But technically it's not exactly specified *when the cleanup happens*. Why such a limitation? That's for technical reasons. If an object has lost all other references (like `john` in the code above), then it is to be garbage-collected automatically. But technically it's not exactly specified *when the cleanup happens*.