JavaScript design using two arrays v.s. one object array, the pron and corn?

Clash Royale CLAN TAG#URR8PPPJavaScript design using two arrays v.s. one object array, the pron and corn?
Let us consider performance, design, readable, what is the better design for JavaScript? Question is that keep a key value table!
design one:
key= ['A', 'B', 'C', 'D']
value = [1, 2, 3, 4]
design two:
map = {'A':1, 'B':2, 'C':3, 'D':4]
design three
map = [ ['A', 1], ['B', 2], ['C', 3], ['D', 4]]
design four:
data = [{key:'A', value:1}, {key:'B', value:2}, {key:'C', value:3},{key:'D', value:4}]
My colleague say 'design one' is the best, because it keep simple, no redundant object, easy to access by index, and have best performance because JavaScript access array is faster than access Map.
However, I think that we need to put relationship data together in order to reach
Encapsulation. I don't known how more time be waste if using Map? Is it really very slow than use Array?
How do you think?
Two is the normal way. The others are strange. Consider a JavaScript array is basically a map keyed by ints anyway.
– Nathan Hughes
27 mins ago
First, that's not a Map, is a key-value pair object instead. The best approach it depends on the current design. Btw, this is a primarily opinion based question!
– Ele
25 mins ago
There is technically no right or wrong answer to this question because we don't have the context in which you will be using it. Your colleague is wrong because you should never optimise things like this at the start of a project and you can't optimise without benchmarks. Pick the one that makes your data easier for you to work with.
– Emett Speer
13 mins ago
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
"access array faster than map" .. that is silly. Create a perf test and test both yourselves
– charlietfl
27 mins ago