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 array contains information related to the the larger one, but not every element of large
requires an associated element in small
and so I set it to null
. However, I do still need to keep the indices the same so I can do things like large[16].id + ': ' + small[16].description
. Does the fact that I've got an array that's mostly null
in value result in increased memory usage?
My question is whether or not I'd be better off doing something like small = [a2,b2,c2,i2]
, and setting indices in properties like a2.index = 0; b2.index = 1
and so on.
I've also come across a suggestion to use undefined instead and someone even mentioned implementing linked lists. I don't think I need to implement a linked list since I'm not adding or removing elements very often.