Array Limit in JavaScript


What would be a recommended limit for the number of items in an array? I appreciate it’s depended on the machine/ platform used, but let’s say we are using a average computer from these days and Chrome.

To give more context, I want to make an API call and retrieve up to 10k items and store them in an array. The items will be some IDs. There will be 2 such arrays and I want to compare them to see how many items overlap.

Would this task be doable in a browser using JavaScript?


You seem to know your problem size (n <= 10k)
So you could set your array size to 10000. If you anticipate n growing, you can find a way to allocate more memory.
When choosing a container you have to think about what you will be doing with the data inside the container. Each container has pros/cons depending on what you do with the data (insert/remove in the front/back/middle, remove elements) etc etc


Thanks for your reply. So the array limit is 10k indeed? and what do you mean about choosing a container, can you give a few examples to have starting point to dig deeper? Sorry but I am still new to coding and I lack many of the basic concepts.

Thank you,


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.