Re: problems with associative arrays
- From: ZER0 <zer0.shock@xxxxxxxxx>
- Date: Fri, 30 Sep 2005 10:09:55 +0200
On 30 Sep 2005 00:33:38 -0700, nkparimi@xxxxxxxxx wrote:
> var IDToAddress = new Array();
> IDToAddress['1000000'] = 'apple tree lane, mars';
> IDToAddress['2000100'] = 'orchard street, venus';
Use simply object, not Array:
var IDToAddress=new Object();
IDToAddress['1000000'] = 'apple tree lane, mars';
IDToAddress['2000100'] = 'orchard street, venus';
with object initializer:
ex. 1
var IDToAddress={};
IDToAddress['1000000'] = 'apple tree lane, mars';
IDToAddress['2000100'] = 'orchard street, venus';
ex. 2
var IDToAddress={
'1000000':'apple tree lane, mars',
'2000100':'orchard street, venus'
}
IDToAddress['key']="something";
You can reference the properties with dot notation or squadre bracket
notation:
alert(IDToAddress.key);
alert(IDToAddress["key"]);
This works for all object:
window["alert"]("hello world");
window.alert("hello world");
And you can iterate the properties with for..in statement.
In addition, you can find on net a lot of "classes" for more complex hash
objects.
I hope it helps, and sorry for my english.
--
~ Io non soffro di pazzia, ne godo ogni minuto.
(I don't suffer from insanity, I enjoy every minute of it)
.
- References:
- problems with associative arrays
- From: nkparimi
- problems with associative arrays
- Prev by Date: Re: Non-deprecated arguments
- Next by Date: ajax + prototype.js + multipart/form-data
- Previous by thread: problems with associative arrays
- Next by thread: Re: problems with associative arrays
- Index(es):
Relevant Pages
|