Will 1,000,000 items be created?
No, arrays are sparse, but their index will be constant. EDIT: Actually, their sparseness would be implementation-specific, but keeping them sparse in the case of a[1000000] = 1 would seem logical to me.
var a = [1, 2, 3, 4]; var x = a[1];
Are JS arrays associative?
JavaScript arrays are a subset of associative arrays (these indices must have integers, as shown by KennyTM . JavaScript objects are fully associative:
var o = { "key1": "value1", "key2": "value2" }; var i = "key2"; var v = o[i];
Tomalak
source share