[thelist] Q on assoc arrays
jsWalter
jsWalter at torres.ws
Sun Dec 14 21:56:53 CST 2003
> -----Original Message-----
> From: Simon Willison [mailto:cs1spw at bath.ac.uk]
> Sent: Sunday, December 14, 2003 8:41 PM
> To: jsWalter at torres.ws; thelist at lists.evolt.org
> Subject: Re: [thelist] Q on assoc arrays
<snip>
> The solution to your problem is to use "object literal" syntax, which
> looks like this:
>
> var myArray = {
> ac: 'Ascension Island',
> ad: 'Andorra',
> ae: 'United Arab Emirates',
> af: 'Afghanistan'
> };
>
> That will create an object called "myArray" prepopulated with all of
> your data.
That's it! You took it one level back *up* from the example on
http://www.crockford.com/javascript/survey.html
That's what I'm looking for!
> Here's an interesting side-note: if you do the above, you'll be able to
> access data from the object using either of the following forms:
>
> var country = myArray['ac'];
>
> or
>
> var country = myArray.ac;
Yes, this is *exactly* the "side effect" I'm looking for!
Thank you very much!
Walter
More information about the thelist
mailing list