Internet Explorer has no problem creating an array of 65,536 elements.
var array = [];
for(var i = 0; i < 65535; i++)
{
array.push(i);
}
array.push(i);
alert(array.length); // says 65536
However, IE does have a problem eval-ing an array of 65,536 elements.
var buffer = '[0';
for(var i = 0; i < 65535 / 15; i++)
{
buffer += ',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0';
}
buffer += ']';
var array = eval(buffer);
alert(array.length); // would be 65536,
// if it got this far..
The code produces an out of memory error on the eval statement. The limit for eval appears to be 65,535 – a number that harkens back to the dark, dismal days of programming in a segmented memory architecture.
Of course, if you came here looking for the upper limits of eval – you might be doing something wrong!