Merge pull request #266 from usernamehw/patch-13

Update article.md
This commit is contained in:
Ilya Kantor 2017-11-01 10:49:49 +03:00 committed by GitHub
commit ff01c05d2a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -408,7 +408,7 @@ The most notable limitation of `WeakMap` and `WeakSet` is the absence of iterati
## Summary ## Summary
- `Map` -- is a a collection of keyed values. - `Map` -- is a collection of keyed values.
The differences from a regular `Object`: The differences from a regular `Object`:
@ -421,12 +421,12 @@ The most notable limitation of `WeakMap` and `WeakSet` is the absence of iterati
- Unlike an array, does not allow to reorder elements. - Unlike an array, does not allow to reorder elements.
- Keeps the insertion order. - Keeps the insertion order.
- `WeakMap` -- a variant of `Map` that allows only objects as keys and removes them once they become unaccessible by other means. - `WeakMap` -- a variant of `Map` that allows only objects as keys and removes them once they become inaccessible by other means.
- It does not support operations on the structure as a whole: no `size`, no `clear()`, no iterations. - It does not support operations on the structure as a whole: no `size`, no `clear()`, no iterations.
- `WeakSet` -- is a variant of `Set` that only stores objects and removes them once they become unaccessible by other means. - `WeakSet` -- is a variant of `Set` that only stores objects and removes them once they become inaccessible by other means.
- Also does not support `size/clear()` and iterations. - Also does not support `size/clear()` and iterations.
`WeakMap` and `WeakSet` are used as "secondary" data structures in additional to the "main" object storage. Once the object is removed from the main storage, so it only stays in `WeakMap/WeakSet`, they clean up aumatically. `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.