|
|
|
|
|
by Klathmon
2961 days ago
|
|
It's "My hovercraft is full of eels", not "My hovercraft has an arbitrary amount of eels in it"! Now looking at the ES5 spec [0], the max length of an array is an unsigned 32-bit integer due to the `ToUint32` operation that the spec defines. So that means our `craftCapacity` here needs to be 2^32-1 Sadly we can't use `Number.MAX_SAFE_INTEGER` here because that assumes double-precision floating points as the underlying storage method, so we just have to hardcode our value: const hovercraft = Array(4294967295).map(() => 'https://imgflip.com/meme/Bad-Joke-Eel')
[0] While the spec says this in a roundabout way, i'm not sure if any implementations actually adhere to this limit, and i'd guess most convert the array to a hashtable internally long before it gets to that size. |
|