Set in JavaScript – Sets allow you store unique values

TimeOdd Stories - Set in javascript

Sets allow you store unique values. So instead of filtering lists for duplicates, items can just be inserted into a set then extracted from. For example, to unify to sets of asynchronous data with no duplicates

unique values
Credit :Jacob-Friesen

Which requires much less setup to get the unique parts. Normally, some kind of map would have to be used, then its keys would have to be extracted.

Unfortunately, sets track uniqueness in objects by reference and not value. So just inserting objects will not ensure they have they are unique in most cases. But for primitives (like Number), they work very well.


What do you think?

5 points

Total votes: 0

Upvotes: 0

Upvotes percentage: 0.000000%

Downvotes: 0

Downvotes percentage: 0.000000%

Written by TimeOdd

TimeOdd is a leading technology media property, dedicated to obsessively profiling startups, reviewing new Internet products, and breaking tech news.



TimeOdd Stories - Headset

Occipital launches low-cost AR/VR tracking platform for across the board headset

How to stop stressing soon and stay happy