DEV Community

Discussion on: JS Performance: Perhaps We Shouldn't Always Use Arrays

Collapse
 
nimmo profile image
Nimmo

Tell me more! :-) (please :-D )

Collapse
 
rhymes profile image
rhymes

It's a new ES6 addition but sometimes they come in handy, you can add elements, you are sure they are unique and you can ask if the element is in there without enumerating everything. If you need to associate a key with values Map is a better choice though developer.mozilla.org/en-US/docs/W...

Thread Thread
 
nimmo profile image
Nimmo • Edited

Ah my apologies, I should have asked my question better than "tell me more", but thank you for the detail!

What I really meant was "how would I use a Set to allow findMyCat('Dante') to work?" In the interests of understanding better is all - I agree that a Map (which I now exists thanks to the comments on this post :-D) would have been a better choice here.