Quantcast
Channel: Arrays vs Maps for listing items that have a unique id - Software Engineering Stack Exchange
Browsing all 3 articles
Browse latest View live

Answer by mtj for Arrays vs Maps for listing items that have a unique id

It seems to me that in a scenario where 'You have a list of items, andthey have some kind of unique key' then a map is always (or usually)advantageous to use.However, from a code readability and 'the...

View Article



Answer by Avner Shahar-Kashtan for Arrays vs Maps for listing items that have...

The guiding principle for choosing a data structure should be its usage, not its members. If, as you say, you only need the items to render sequentially, an array is perfectly fine. If you need to...

View Article

Arrays vs Maps for listing items that have a unique id

I've been finding that for a lot of code I've been writing recently, it naively might look like this:Array approach:const options = [ { id: 'red', label: 'Red', data: '#f00' }, { id: 'blue', label:...

View Article
Browsing all 3 articles
Browse latest View live




Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>