Which is faster array or object?

Write chat on nodejs. Store data in the form of the object.
const company = {
 2: {
 id: 2,
 company_name: 'My company',
 users: {
 1: {
 id: 1,
 name: 'John',
 messages: [...]

Like this. I keep the data in the object, not the array for two reasons:
1) it is more convenient to handle. For example, I can directly in the markup (I use Vue) display the user name.
<span>{{ companies[company_id].users[user_id].name }}</span>

2) it's faster, because we go right to a specific property.

Then I decided to look at the difference. Wrote a small script that ran in the browser.
The essence of the script is that he's a million times looking for the data in the array and in the object. Simplified it looks like this:
const objResult = obj[key];
const arrResult = arr.find(el => el.id === key);

To my horror a search through the array of orders of magnitude faster.
I guess the browser caches anything at all in the browser such to carry out measurements properly. Then I went to the Internet and the first question on the stackoverflow write "mostly Arrays are faster than objects".
I looked at different sources, opinions differ.

Please explain why such a question even discussed and is the place to be? After all, the object is accessed by key - this is not a search. The script knows from the start and immediately gets the data. In the mountains opposite is always brute force the entire array every time.
April 19th 20 at 12:06
3 answers
April 19th 20 at 12:08
Why do you think that the treatment of key - no search?

The key is a direct address in memory?
No, but then I guess you have to search all objects to find the key?
Need to see the implementation of getter, to understand how it's complicated.
What is the object, not a hashtable? - Sherwood.Beier37 commented on April 19th 20 at 12:11
April 19th 20 at 12:10
It reminded me of a story when a speaker compared the search in Yandex and direct indication of the site in the address bar. Type, when he writes the address of the site, it immediately goes to him and the alleged search is not included. However, even when directly specifying the address of the site still included search: you entered the address of the website, but it's not the exact path to the server where the data is stored. While there is a request for data, and yet they go back, included several searches at different stages.

So it is here. In fact, the system need to get some value from memory. Arrays are initially sharpened by machine memory organization: on a point of order. It is logical to assume that if you have N-e value, the faster it will get out of memory, as it N-e in the memory, starting from some cell (roughly speaking). More complex associative arrays (or objects) are organized in memory more difficult (sorry for tautology). An associative array is at least two ordinary array. Accordingly, by searching for it, have been working for at least two searches.

it's always searching through the entire array every time.

If the keys are unique, and in regular javascript arrays so, it is unlikely that the search continues after finding the desired item.

In General, the web application is not really the area where we need to optimize queries based on the architecture, I mean, when you get a win in a few milliseconds. The page loaded a few seconds the animation lasts 0.3 s, and so on - against this background, the payout will be zero, even with 1 billion users online )

On the merits, I think you all are doing is absolutely right, because on the web the most important is the convenience of continuous development of the project. If the code superficially, and logically similar to the way data is organized in everyday perception, it is convenient: quickly understand and can be modified.
April 19th 20 at 12:12
You need to take a broader look at the problem, to understand how serious

Find more questions by tags JavaScript