I found this article “Javascript ‘Associative Arrays’ considered harmful” while trying to figure out wtf was wrong with my javascript arrays:
(excerpts)
given this code:
var associative_array = new Array();
associative_array["one"] = “Lorem”;
associative_array["two"] = “Ipsum”;
associative_array["three"] = “dolor”;
for (i in associative_array) { alert(i) };It works because all you�re doing is setting properties on an object and a for..in loop simply iterates over an object�s properties.
However, one really ought to use Object for a set of key/value pairs.
The harmful side effects of using Array for key/value pairs are not experienced unless Array.prototype is extended.
scriptaculous (helps create pretty dynamic pages) is built on prototype (not to mention other things that may be useful).
I thought this might be important to note since there are some tutorials that don’t mention this problem.






Interesting.
I seem to recall (years ago, when I was working in JavaScript) running into a similar problem with prototype, and so I think recommending that Object be used instead for this functionality is valid advice.
By the way, if you want to see JavaScript used for development purposes in addition to websites, you might want to check out Dreamweaver; several of the product is written in an API that entirely uses html and javascript. The javascript development files — and there are *tons* of them, are located in:
[dreamweaver program folder]/Configuration/*
(I had a job coding these files at one point in my life.)
P.S. I got here because you’re a member of ucberkeley. I’ll be a (female) junior transfer there in the fall hoping to major in computer science.