June 2016
Beginner
314 pages
6h 19m
English
Along with the two new data structures Set and Map, ES6 also introduced a weak type version of these classes: WeakMap and WeakSet.
Basically, the only difference between the Map or Set classes and their Weak versions are:
WeakSet or WeakMap classes do not have the entries, keys, and values methodsThe reason for creating and using these two classes is performance related. As WeakSet and WeakMap are weakly typed (using object as a key), there is no strong reference to the keys. This behavior allows the JavaScript garbage collector to clean an entire entry from the map or set.
Another advantage is that you can only retrieve a value if you have its key. As these classes ...
Read now
Unlock full access