* Dmitriy Sintsov questpc@rambler.ru [Thu, 22 Mar 2012 11:15:40 +0400]:
In Chrome, executing the following code: var a = []; a[0] = 'a'; a[2] = 'c'; worked, however debugger inspector shows 'undefined' elements between real elements of array. And the length is counted for 0..last element, including the undefs. However, for..in worked for such arrays fine,
but
may be inefficient - I do not think it has hashes or linked lists to skip the undefs, it probably just skips them one by one. That worked
in
IE8/IE9/FF/Chrome so I must not be first coder who used that.
I switches to {} and $.each() two days ago, so that's already the
past.
Maybe the efficient and simple way for sparse arrays would be maintaining non-sparse array for sparse keys for..in with that array then using "numeric string" object properties to get / set actual values? I don't know, the speed is not so critical in my usage case.
- Sparse objects don't exist in any language afaik. What you created
is
just a regular plain object.
I was mentioning JS objects with numeric keys - I didn't know they are silently converted to numbers. Now I removed parseInt() from my code.
Mistyped, silently converted to strings, of course.
MediaWiki with extensions does a lot of requests, which requests do load extension messages? I'll try to find. Dmitriy