Sniberb
Sniberb3y ago

⛄ Snowberb ⛄ – 15-39 Jun 25

I do not know how to search this question in google, so I'll write it here. I want to create an array of objects like this:
const bets = ["key": {object}, "key": {object}, "key": {object}]
const bets = ["key": {object}, "key": {object}, "key": {object}]
key being a uuid that I will randomly generate, and all that data comes from another array of objects which is like this: const savedBets = [{}, {}, {}...] I've heard of Hash maps but I never used one. Is that the best way to transform savedBets into the structure that I want?
9 Replies
Sniberb
SniberbOP3y ago
I need to have an array of key: value because I have to create/delete entries
Eva
Eva3y ago
You can delete entries from objects/Map too, what's the problem with them?
Sniberb
SniberbOP3y ago
There's no problem I just don't know what to use
Eva
Eva3y ago
I'd probably recommend Map, good for key-value storage, and easily iterable too
Sniberb
SniberbOP3y ago
Map is more performant than Object for creation and deletion right?
Eva
Eva3y ago
It's generally better than object but in reality it could be a liiitle bit worse than object too
Sniberb
SniberbOP3y ago
why worse?
Eva
Eva3y ago
Could be few nanoseconds faster if working with just a few entries, but in general Map is a lot better than object in all the aspects
reactibot
reactibot3y ago
This thread hasn’t had any activity in 12 hours, so it’s now locked. Threads are closed automatically after 12 hours. If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/990280118528262215