December 15, 2004

There's no such thing as an associative array in ECMAScript/Javascript.

This thread on Javascript Arrays is quite good. And incredibly informative. It might be one of the best walkthroughs of Objects in Javascript that I’ve read. I highly recommend going and reading through it. At least cover the first page fairly well.

Just to dispel any misconceptions, there’s no such thing as an associative array in ECMAScript/Javascript. What you are actually using is a feature of objects - their ability to have properties added at run-time.

> var users = new array();
> users["joe"] = "Joe Blow";
> users["john"] = "John Doe";
> users["jane"] = "Jane Doe";
Using an actual array is a waste. You aren’t using it to store values by ordinal number, you’re just using the fact that it’s an object.

Just some really interesting stuff. Well worth your time. And for more Javascript goodness, I’ll toss out the JavaScript FAQ, the comp.lang.javascript group.

Post Info

Tagged As Javascript

Comments are Open (0)

Posted at 11:44 AM

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

Search
Comments on this post
Categories
Info
Tony Stephens
Copyright © 1995-2005
Site Version:
10
Licensed:
Creative Commons
Validate:
XHTML, CSS, 508, RSS
Subscribe
Blog-Fu, Link-Fu