Let's see some cases to indetify which data strctures to use when.
Use when you need ordered list of values and might contain duplicates
Use when you need to manipulate data because there are a lot of useful array methods
Set's looks the same as an array but it also has some scenarios when we consider using sets over the array.
Sets are really not meant to replace arrays but rather to complement them whenever we are dealing with unique values.
Let's see possible cases where we can use sets:
Use when you need to work with unique values
Use hen high-performance is really important because operations like searching for an item or deleting an item from a set can be up to 10 times faster in sets than in arrays.
Use to remove duplicates from an array
Objects is the traditan key value data strcture before maps introdcues in ES6 but using objects simply as key value stores has a couple of technical disadvantages
Use when you need to include funcitnas or methods
Use when working with JSON(can convert to map)
Maps on other hand are way better suited for simple key vakue stores because they offer better perforamce in fact
Also map keys can have any data typpe and they are also easy to iterate and its easy to compute the size of map
Use when you simply need to map key to values
Use when you need keys that are not strings
Do let me know If you face any difficulties please feel free to comment below we love to help you.
If you have any feedback suggestion then please inform us by commenting.