Arrays Data Structure

Last updated on 3 Dec, 2022

The idea behind Arrays is that it occupies contigous memory locations. And also, the number of memory locations allocated are pre defined.

So if we have an array of 3 integers and if each integer takes 4 bytes of space, then overall we require 12 memory locations for the array.

In JavaScript, when we do const arr = [2, 3, 4], in the backend it is not purely stored in contigous memory locations.

If we want to ensure contigous memory locations, we need to use ArrayBuffer.

--- ○ ---