Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm not sure if I'd characterize Javascript's handling of arrays and hashes as conflated. The two are treated differently. To take an example from the post, Javascript Objects (hashes/Associative arrays) do not have a splice function.

To answer your question I don't know of many languages which conflate the two. I know a lot of languages which offer similar methods, to create parity between arrays and hashes (since they are similar enough data structures) but not many which treat them the same.



> 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.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: