commit
ff01c05d2a
1 changed files with 12 additions and 12 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue