> For future reference what should I have put in the subject line on this one?
How about "Handling great number of variables efficiently?" ... uhm ... I'd say something like
"Scaling this script to deal with many variables" ... maybe "Big amout of data makes coding painful" ... "Bad
efficiency when introducing many variables" ... "Script won't scale well"
Well, something like that. I'm not an authority on subjects, either :)
Take the above proposals, insert own ideas randomly, and throw together your own subject from that. :)
Also, is there a limit on how many characters I can put in an array?
Don't know exactly ... I just conducted a quick test and was able to create two arrays, containing 100000 and
half a million string objects, though that took a while on my old machine:
Creating array w/100,000 elements*
Opera 0.8 sec, IE 6.5 sec
Creating array w/500,000 elements*
Opera 3.3 sec, IE 2 min 40 sec
Didn't check two- or more-dimensional arrays though. (Maybe you've noted that the code I posted contained a
2-d array, which is basically an array containing arrays. Imagine an array as a "list" of things (has one
column), and a 2-d array as a "table" of things (has >1 column)--like the "links" array containing entries
that were in themselves arrays containing name and url.)
So I guess in terms of processing time, element counts with five figures will generally be ok on pretty much
every system; with element counts greater than that you are on the verge of becoming annoying for some users.
Also bear in mind that Javascript is completely client-side, so every chunk of data you may want to access via
script has to be transferred to the client (i.e.: everything must be in your page's source code, which has to
be downloaded prior to execution). So if you shovel, say, the humongous multi-megabyte database (contained in
a Javascript) through the visitor's 56 K connection, you'd better have one heck of a good reason for that :)
You can certainly put a lot of data into the arrays on your page, but keep an eye on the file size.
Good coding!
Best regards
Hendrik Krauss
* all figures: Opera 7.20, Internet Explorer 6.0, Athlon 1.2 GHz, 512 MB RAM, WinXP