WeakSets are one of the most undervalued keyed collections. A keyed collection is basically collections of data that are ordered by a key. I recently wrote an article about their sibling, WeakMaps.
For us to fully understand the beauty of WeakSets, we have to first learn about their bigger sibling — Sets. Let’s now learn what Sets are.
Now you might start to wonder, how can Sets be keyed while arrays are indexed. The reason is that you cannot access a value in a set by its index. This is because these values are arranged as key-value pairs. The reason why Sets do not allow duplicate values is that the keys are the same as the value. This would result in a duplicate entry causing no harm to the uniqueness of the values in the Set.
You can iterate the values in a Set by in the order of insertion by using the iterator. As I have explained above, a value in a
Set may only occur once; it is unique in the
Here are some of the differences between these two collections.
Does your business need an interactive website or app?
The technology used to develop the overall app by the developers from WebClues Infotech is at par with the latest available technology.
For more inquiry click here https://bit.ly/31eZyDZ
Book Free Interview: https://bit.ly/3dDShFg
With 15+ years of domain expertise, we have successfully delivered 13800+ projects and have successfully garnered 6800+ happy customers with 97%+ client retention rate.
The callback now receives an accumulator (it accumulates all the return values. Its value is the accumulation of a previously returned accumulations), a current value, a current index, and finally, the whole array.