Update article.md

This commit is contained in:
Alexander 2017-10-22 00:40:40 +03:00 committed by GitHub
parent ccc0e9327f
commit c2eea5dee6

View file

@ -408,7 +408,7 @@ The most notable limitation of `WeakMap` and `WeakSet` is the absence of iterati
## Summary
- `Map` -- is a a collection of keyed values.
- `Map` -- is a collection of keyed values.
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.
- 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.
- `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.
`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.