0

Can I get an array of 10 figure numbers using Javascript from 1? so that I can manipulate the array ? If yes how can I ?

15th Jul 2020, 7:23 AM
Shantiram
Shantiram - avatar
3 Respostas
+ 6
If I got this right you want an array that starts from 1 and goes up to 9,999,999,999. It certainly is possible to create such a huge array with a simple for loop. But it will be slow. Let arr = []; for(let i=0; i<9999999999; i++) { arr.push(i); } Why would you need such a huge array anyway? You may want to look into sparse arrays if your array will be mostly empty (contains a lot of zeros) because they are significantly faster. https://en.m.wikipedia.org/wiki/Sparse_matrix
15th Jul 2020, 8:47 AM
Haris
Haris - avatar
15th Jul 2020, 9:01 AM
Ipang
15th Jul 2020, 8:01 AM
Omkar Kamat
Omkar Kamat - avatar