4 ms·
Hmm, looking at the source code, you are partially correct. https://github.com/v8/v8/tree/master/src/objects https://github.com/v8/v8/tree/master/src/objects I
by batmansmk 8y ago
Hmm, looking at the source code, you are partially correct. https://github.com/v8/v8/tree/master/src/objects https://github.com/v8/v8/tree/master/src/objects
I can see at least 10 types which are not hash maps. Including all the flavors of Typed Arrays.
- squeaky-clean 8y agoThat's just how it optimizes their usage under-the-hood, but as far as JS is concerned they are all hash maps. For example, try this: var foo = [1,2,3]; // or `foo = new Array(1,2,3)` also works foo['bar'] = 'test'; console.log(foo); and you get: 0:1 1:2 2:3 bar:"test"
- arghwhat 8y agoAh yes, I had forgotten about Typed Arrays, which is a terrible name for what is in fact a buffer view. The entire arraybuffer/typedarray system was a later (≥IE10 if I am not mistaken?) hack added to make up for the fact that Array and Number are super inefficient for data processing. But regardless of them being a bandaid, you are correct that it is an exception. ArrayBuffer and all its views count 10 types in total, so were they the only exception? If so, I believe my point still stands.