Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it advisable to use arrays in Javascript using tens of thousands of indexes?

Is it advisable to use arrays in Javascript using tens of thousands of indexes?

I have a database which contains a table of static data, meaning that it will never change. In this case would it be advisable to convert this table to a javascript array and look the info up in there when needed? Is this bad practice?

The table in question contains roughly 40,000 key/value pair entries.

like image 482
Gary Willoughby Avatar asked Nov 24 '08 20:11

Gary Willoughby


1 Answers

No.

I'd keep the table, as its a single point of maintenance.

You'll find that doing a XmlHTTPRequest to return a key/value pair based on a server side query, would actually perform faster, and have significantly less memory footprint than a huge JavaScript array.

like image 169
FlySwat Avatar answered Oct 04 '22 02:10

FlySwat