The length of the array changes only when adding numeric indices. For instance,
pollData["randomString"] = 23;
does not affect the length but
var pollData = []; pollData["45"] = "Hello"; pollData.length;
changes the length to 46. Note that it does not matter if the key was a number or a string if it is a numeric integer.
In addition, you should not use arrays in this way. Consider this more likely a side effect, since arrays are also objects, and in JavaScript any object can contain arbitrary keys as strings.
source share