Tagged Questions

10
votes
4answers
403 views

Does null occupy memory in javascript?

I've got the following situation: var large = [a,b,c,d,e,f,g,h,i]; var small = [a2, b2, c2, null, null, null, null, null, null, i2]; where every element of both arrays is an object. The small ...
2
votes
3answers
143 views

javascript sort sparse array keep indexes

What is the best method to sort a sparse array and keep the elements on the same indexes? For example: a[0] = 3, a[1] = 2, a[2] = 6, a[7] = 4, a[8] = 5, I would like after the sort to have ...
0
votes
4answers
101 views

Condensing a sparse array in Javascript?

I have an array of elements where the entries are sparse. How can I easily condense the sparse array into a dense array so that I don't have to keep checking for null and undefined values every time ...
3
votes
2answers
148 views

Are JavaScript/ECMAScript arrays “sparse” in Node.js?

My question is the same as Are Javascript arrays sparse? with one difference... Are JavaScript arrays sparse, as implemented in Node.js (and/or V8)? I had assumed the were, but then I did the ...
2
votes
4answers
2k views

Get first element of a sparse JavaScript array

I have an array of objects in javascript. I use jquery. How do i get the first element in the array? I cant use the array index - as I assign each elements index when I am adding the objects to the ...
2
votes
2answers
301 views

JSON implementations that handle sparse arrays

I need to know if any JSON implementations can handle sparse arrays to my satisfaction. I've seen the question: http://stackoverflow.com/questions/1733658/how-to-represent-a-sparse-array-in-json but ...
26
votes
4answers
4k views

Are Javascript arrays sparse?

That is, if I use the current time as an index into the array: array[Date.getTime()] = value; will the interpreter instantiate all the elements from 0 to now? Do different browsers do it ...
1
vote
2answers
770 views

Recommended way to map between JavaScript sparse array and C# (sparse)array?

I am trying to map a JavaScript sparse array to a C# representation. What is the recommended way of doing this? It am considering using a dictionary containing the list of oridinals that contained ...
2
votes
2answers
2k views

Help with Sparse Array in JScript

I have a sparse array in Jscript, with non-null elements occuring at both negative and positive indices. When I try to use a for in loop, it doesn't traverse the array from the lowest (negative) index ...