CodingTrain / CodingTrain/Suggestion-Box

ES6 Map and Set objects

Open
#859 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
570
Forks
85
PR merge metrics
No merged PRs in 30d

Description

When should each be used and what kind of data structures would require using them instead of typical objects or arrays.
* [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)
* [Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)

As an aside, although this functionality isn't in the native ES6 Map, I particularly like the `.find()` functionality in [this collection that extends the Map class](https://github.com/discordjs/discord.js/blob/a8172951d3d12feb59b8f0c6d77d23837b8f57e3/src/util/Collection.js#L191-L206) where you're able to pass in a key/value pair and get the full object that contains that reference back. This sort of thing I find especially helpful for large nested objects (where a Map is most useful), and it is a fairly simple function to add to a class that extends Map since it's just one small loop to iterate through each item in the Map.

Anyway, I'd love to see a video on Maps, Sets, or other "Collection" types. Especially since these can also play really well into the higher-order functions that were looked at in a few videos recently.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.