Non-associative arrays in JavaScript ?
Hello,
reading about JavaScript I found that arrays in it are associative. Conceptually it's sufficient, i.e. arrays with numeric index can be mapped onto associative arrays using the numeric index (stringified ?) as hash key. However, there are performance and memory footprint considerations. With associative arrays hash function should be called per access, and from my experience in Perl storing data in hashes takes more memory - which is not surprising - buckets and stuff ( https://en.wikipedia.org/wiki/Hash_table ). I also know that typed arrays are being introduced into JavaScript ( https://developer.mozilla.org/en-US/...t_typed_arrays ). But, IIUC, not all JavaScript engines support typed arrays - the latter do use numeric index like in "C". So, are there other than typed non-associative arrays (the ones using numeric index directly) ? Perhaps as an add-on module and/or bindings to some code written in "C" ? Thanks in advance. |
Hi
The typed arrays are supported in all new browsers supporting HTML5. The only problem would be old Internet Explorer versions. Only IE 10 supports it. I think it wasn't really necessary before WebGL. Traditionally, we would use Ajax calling a database on a server to deal with lots of data. If all you need is a lookup in a big data set, you could write the data as a long string and use charCodeAt, but changing the data would be a problem. The only thing I can think of for old browsers is using ActionScript (flash) or something. Arrays in ActionScript are always indexed by integer, but they're sparse arrays, so I'm really not sure about how it does the lookups. Here's a good guide by the way: http://www.html5rocks.com/en/tutoria.../typed_arrays/ |
Quote:
Anyway, the question is more general than just typed arrays. I am looking for elastic non-associative arrays which can store elements of "any" type - like Perl arrays do. |
Quote:
|
Quote:
Quote:
|
Quote:
Quote:
|
All times are GMT -5. The time now is 07:08 AM. |