Although here are already two good answers, I'd like to specifically address your question if you feel "paranoid" to use an array with many unfilled elements.
JS arrays are tricky as they may appear as "linear lists" as well as "dictionaries". If you use them as "dictionary", you are actually using JS Object properties. So you are mixing contents.
Try this:
var a = [];
a[10] = "the entry";
console.log("A seems to have a length of: " + a.length);
console.log ("Contents of a:");
for (var key in a) {
console.log("- key " + key + " has: " + a[key]);
}
Result:
"A seems to have a length of: 11"
"Contents of a:"
"- key 10 has: the entry"
There is actually only one element stored. This shows that length is just an information. It is an upper border that has been set in order to keep the array consistent, if it is seen as integer-addressed chain of elements. Here, length is not related to "size of memory allocated". There are no "empty storage places".
For some followup questions, you may try this change too:
var a = [];
a[5] = "the earlier entry";
a["the_key"] = "disturbing";
a["2015"] = "Top";
a[10] = "the entry";
console.log("A seems to have a length of: " + a.length);
console.log ("Contents of a:");
for (var key in a) {
console.log("- key " + key + " has: " + a[key]);
}
New result:
"A seems to have a length of: 2016"
"Contents of a:"
"- key 5 has: the earlier entry"
"- key 10 has: the entry"
"- key 2015 has: Top"
"- key the_key has: disturbing"
You can always use the Array context as well as the Object context.
This has consequences, e.g. for how to loop an array (it is already a huge discussion, jQuery's .each() adds some more questions :-) ).
With the classic for loop, you have to check if an element is undefined. (Remove the above key "2015" first).
for (var i=0; i<a.length; i++) {
console.log("at i=" + i + ": " + a[i]);
}
Shows:
"at i=0: undefined"
"at i=1: undefined"
"at i=2: undefined"
"at i=3: undefined"
"at i=4: undefined"
"at i=5: the earlier entry" <<<
"at i=6: undefined"
"at i=7: undefined"
"at i=8: undefined"
"at i=9: undefined"
"at i=10: the entry" <<<
The object loop with in shows the keys.
Finally, it seems you have clarify the Array methods how they act for a linear array and if this is what you expect. indexOf(), for example, acts like for a linear array. indexOf() is defined for Array, not for Object. Therefore indexOf() won't return you an alphanumeric key but only linear index positions.
http://www.javascripture.com/Array
http://www.ecma-international.org/ecma-262/5.1/#sec-15.4
data[2015] = []