I wanted t create a large array in Javascript and wrote the following code but it did not work due to OOM
let N = 125000000;
let numbers = [];
for (let i = 0; i < N; i++) {
numbers[i] = Math.round(Math.random()*10000);
}
Then I wrote "let numbers = new Array(N);" instead, which worked for the N (125000000) but did not work with larger N (200000000). Then I used Uint32Array, which worked for even larger N. It worked up to N = 2^31-1. Is there any limit on size in [], new Array(size), Uint32Array in Javascript? I guess the max size o Uint32Array is 2^31-1. I also want to know why new Array(N) has higher limit than []. Thank you