2 ms·
It is the same for Javascript: even though you have an Array object that you can instantiate instead of the more generic Object, they are much the same thing un
by cygx 15y ago
It is the same for Javascript: even though you have an Array object that you can instantiate instead of the more generic Object, they are much the same thing under the hood with both arrays and objects being hash maps
While this is true if you only consider language semantics, implementions do use actual arrays to store dense properties with integer names, ie arrays are backed by both flat and sparse storage with some heuristic algorithm to determine when to use what.
- dspillett 15y agoGood point. Presumably that is one of the differences in array performance between modern browsers and their eldery relatives.