I am relatively unfamiliar with JavaScript, and I was recently told that a JavaScript array contains a length
variable of type Number
. This length is automatically updated as the array is updated to the number of elements in the array.
However, I was also told that internally, JavaScript uses a 64-bit floating point representation for its Number
class. We know that floating point arithmetic cannot exactly represent all integers within its range.
So my question is, what happens with large arrays, where length + 1
cannot exactly represent the next largest integer in the sequence?