Array vs linked list: race them in your browser
Textbooks say arrays win at random access and linked lists win at inserting at the front. Run the same four operations on a real JavaScript array and a real singly linked list and see the actual gap on your machine.
What you should see
Random access: the array wins by orders of magnitude, because it jumps straight to index i while the list walks i nodes. Insert at the front: the linked list wins, because the array has to shift every element. Iterating is close here, and may even favour the list: a list built in one go gets its nodes allocated side by side, so it behaves almost like an array. In long-running programs, where nodes are allocated at different times and scattered across memory, arrays usually win because CPU caches love contiguous data. Appending is fast for both (amortised O(1) for the array, O(1) with a tail pointer for the list). Timings vary by browser and machine, and JavaScript engines optimise arrays heavily, so treat the numbers as a picture of the trend, not a law. Read the full comparison →