The JavaScript exception "Invalid array length" occurs when specifying an array length that is either negative, a floating number or exceeds the maximum supported by the platform (i.e. when creating an Array
or ArrayBuffer
, or when setting the length
property).
The maximum allowed array length depends on the platform, browser and browser version. For Array
the maximum length is 4GB-1 (2^32-1). For ArrayBuffer
the maximum is 2GB-1 on 32-bit systems (2^31-1). From Firefox version 89 the maximum value of ArrayBuffer
is 8GB on 64-bit systems (2^33).
Note: Array
and ArrayBuffer
are independent data structures (the implementation of one does not affect the other).