-3

I am trying to fill an array but when I fill it more than a certain size it stops working.

Is there any size limit on arrays in JavaScript? Is it specified anywhere?

I'm interested in a general answer, but I've spotted it not working using chrome on Windows.

3
  • What do you think the limit is? Can you reproduce the issue in a jsfiddle? Commented Feb 18, 2015 at 14:54
  • 1
    How absolutely humongous are the arrays you're working with? Or is the problem maybe in some other piece of code? Commented Feb 18, 2015 at 14:55
  • the maximum length of an array according to the ECMA-262 5th Edition specification is bound by an unsigned 32-bit integer due to the ToUint32 abstract operation, so the longest possible array could have 232-1 = 4,294,967,295 = 4.29 billion elements. Are you using more than that ? Commented Feb 18, 2015 at 14:57

1 Answer 1

1

The maximum length of an array is 4,294,967,295 - that is, the maximum unsigned 32-bit integer.

Testing in the browser console yields this result:

Screenshot: Array of size 4,294,967,295 works, but +1 length fails

If you're making arrays that big... you have problems. Problems like this guy from Computer Stupidities

At my previous job, we were porting a UNIX system to Windows NT using Microsoft VC++. A colleague of mine, that was in the process of porting his portion of the code, came to me, looking really upset.

  • Colleague: "Hey! I hate these Microsoft guys! What a rotten compiler! It only accepts 16,384 local variables in a function!
Sign up to request clarification or add additional context in comments.

3 Comments

Citation required. Also - is that a theoretical or practical limit? (As in - can you actually create an array this big?)
@BenjaminGruenbaum Testing in a browser console yields this result
Nice, you might want to edit that in.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.