In JavaScript, the basic Array type is dynamic (no permanently fixed size, no fixed type). Typed arrays (Float32Array etc.) are statically sized at allocation time and only contain the specified type.

If you know how many items your dynamic Array is going to hold, you can pass that length into the constructor.

const myArray = new Array(100);

But this wonโ€™t stop you from assigning off the end of the array if you so choose:

myArray[999] = โ€˜fooโ€™; // ๐Ÿ‘

Reply to this note

Please Login to reply.

Discussion

No replies yet.