I use the term loosely as an array in JavaScript can look like this:
let array = [1, 'a', "hello"];
If I do array.push('end') I get
[1, 'a', "hello", "end"]
An array in JavaScript seems to have nothing to do with the arrays taught in Computer Science were all the items are of the same type and this makes it easy to access by index as simple math can be used to determine where each index is in memory.
My assumption would be a single linked list with data being a reference to another object.
It would be cool to see the code if someone knows where it is for the V8 engine.
The source can be found here for V8. Currently V8 implements arrays in two ways:
// The JSArray describes JavaScript Arrays
// Such an array can be in one of two modes:
// - fast, backing storage is a FixedArray and length <= elements.length();
// Please note: push and pop can be used to grow and shrink the array.
// - slow, backing storage is a HashTable with numbers as keys.
So arrays are currently implemented as hashtables or array lists. This has changed in the past, and might change in the future. Also it may vary for other engines.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With