3 ms·
> I'm not sure if I'd characterize Javascript's handling of arrays and hashes as conflated. Insomuch as [] and {} produce arrays and object, yes, you are corre
by __david__ 15y ago
> I'm not sure if I'd characterize Javascript's handling of arrays and hashes as conflated.
Insomuch as [] and {} produce arrays and object, yes, you are correct. But those objects are strikingly similar and the functions in each prototype work on the other. To the outside observer, only the length bit works differently.
I can do:
a = new Array();
a["b"] = 1;
for (x in a) { /* x will be "b" here*/ }
a.length /* 0 */
and
d = {0:"a",1:"b",2:"c",3:"d",length:4}
Array.prototype.slice.call(d, 1,3) /* returns ["b", "c"] */
That's conflated a little bit.