470,591 Members | 1,491 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,591 developers. It's quick & easy.

Maximum number of items in Javascript array

Does anyone know what the maximum number of items (or characters) allowed
is, in a javascript array?

Luke
(I also posted this in alt.www.webmaster so sorry for the duplication)
Jul 23 '05 #1
4 8497


Luke wrote:
Does anyone know what the maximum number of items (or characters) allowed
is, in a javascript array?


An array in JavaScript can have 0..(2^32-1) elements. 2^32-1 is
4,294,967,295.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #2
> An array in JavaScript can have 0..(2^32-1) elements. 2^32-1 is
4,294,967,295.


The array I am using is as follows:

new Array( GetMil(new Date(1992,04,05)), GetMil(new Date(1992,08,22)),
GetMil(new Date(1992,09,16)) etc. which is a set of these date functions and
about 1300 characters

It uses 44 new Date() functions and it had stopped working, however when I
change the dates to 92 instead if 1992 to reduce the number of characters it
starts working again.

Anyone else got any ideas?

Jul 23 '05 #3
Luke wrote:
An array in JavaScript can have 0..(2^32-1) elements. 2^32-1 is
4,294,967,295.

The array I am using is as follows:

new Array( GetMil(new Date(1992,04,05)), GetMil(new Date(1992,08,22)),
GetMil(new Date(1992,09,16)) etc. which is a set of these date functions and
about 1300 characters

It uses 44 new Date() functions and it had stopped working, however when I
change the dates to 92 instead if 1992 to reduce the number of characters it
starts working again.

Anyone else got any ideas?


I have had, in the past, an array that had 34,000+ entries, each being
approximately 80 characters in length. Javascript had no problems with
it. In fact, PHP had more trouble with it than JS did.

First, define "stopped working". Does it not do what it should, does it
crash the browser, lock up the browser, just hang, or what?

What does the GetMil function do? It could very well be that with the
added overhead, it becomes too many things for the browser to handle
(due to overload, RAM, etc...) and it stops execution.

To find out if its the GetMil function, hard code the 44 entries and
work your way backwards until you find the culprit.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jul 23 '05 #4
"Luke" <gr******@hotmail.com> writes:
The array I am using is as follows:

new Array( GetMil(new Date(1992,04,05)), GetMil(new Date(1992,08,22)),
GetMil(new Date(1992,09,16)) etc. which is a set of these date functions and
about 1300 characters

It uses 44 new Date() functions and it had stopped working, however when I
change the dates to 92 instead if 1992 to reduce the number of characters it
starts working again.


That suggests that the problem is not the number of entries in the array,
but the length of the expression.
Are all dates on the same line (that is, a 1300 char line)? If so, try
breaking it up on several lines.

Otherwise, if there is any system to the dates, you can create the array
programmatically with a loop.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by chirs | last post: by
8 posts views Thread by Hal Vaughan | last post: by
11 posts views Thread by Walter Dnes (delete the 'z' to get my real address | last post: by
20 posts views Thread by William Stacey [MVP] | last post: by
2 posts views Thread by Dean Slindee | last post: by
3 posts views Thread by Kriston-Vizi Janos | last post: by
2 posts views Thread by ArtOfSpeech | last post: by
18 posts views Thread by raylopez99 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.