Javascript Code Help.
Javascript Code Help.
Out of context: Reply #6
- Started
- Last post
- 6 Responses
- section_0140
You could use a map (hashmap), or just use an array of objects. The objects would have the advantage of being in JSON format natively. So, if you needed to send it to an API, it's ready to go. The map's main advantage is much faster lookup time.
Keep in mind: maps are not ordered. Each time you iterate over the map, the items could come up in a different order. So, if that's important, use objects.
- ^^^section_014
- Thanks.
The code already "maps" the original array :
{A: "A", 1], ["A", 3], ["A", 4]]}
I was thinking of Array.prototype.map to use chaining.palimpsest - your output is malformed btw
https://jsfiddle.net…dorf - I saw that, thanks.palimpsest
- I guess I'll stay with the tried and true for loop.palimpsest