I am trying to figure out if I can store some strings in an array or if I need an object. Is there a limit to the number of characters allowed in an array item?
5 Answers
The exact maximum limit of an array is 2^32 - 1 or 4294967295, due to restrictions in Javascript's memory. The number of items, also known as the length property, cannot be greater than that. Check this for more details.
5 Comments
Arrays in Javascript are really just specialized objects. There is no difference between what can be put into an array and what can be put into an object because an array is an object. The only difference is that arrays offer access methods based on integer indexes, can be created with [a,b,c] literals, and have a length member.
All memory in Javascript is dynamically allocated and automatically collected, so there are no limits on "the number of characters", other than the amount of RAM available to your program.