A brief introduction to Maps and WeakMaps with ES6, the usage of and difference of Maps and WeakMaps.
I'm not seeing much value in Map
, since I can do an Object.keys(obj)
or Object.entries(obj)
, etc.
When should you use a week Map
?
One difference to Map
objects is that WeakMap
keys are not enumerable. If they were, the list would depend on the state of garbage collection, introducing non-determinism. One use case of WeakMap
objects is to store private data for an object
, or to hide implementation details.
Thank Lauro , a really good explanation. Thank you