![]() |
|
#1
|
||||
|
||||
|
here's my example of a hashmap that i've devised based on this page:
http://www.quirksmode.org/js/associative.html Code:
<script>
var enToNo = new Object
var noElements = new Array("FORNAVN","ETTERNAVN","ALDER")
var enElements = new Array("FIRST NAME","LAST NAME","AGE")
for(var i = 0; i < enElements.length; i++) {
enToNo[noElements[i]] = enElements[i];
}
var norwegianWord = 'ETTERNAVN'
alert(enToNo.ETTERNAVN)
alert(enToNo['ETTERNAVN'])
alert(enToNo[norwegianWord])
</script>
__________________
Nick Humphrey Download for free my experimental music, art, poetry and pictures. My album Classic E B-sides can be purchased on both itunes and amazon.com. Help me improve my phrasebook of world languages. I offer remote healing services. My blog. Last edited by Nickleus : 15-01-08 at 16:30. |
|
#2
|
||||
|
||||
|
Code:
<script>
var x = {};
x["a"]= "1";
x["b"]= "2";
alert(x.b);
</script>
__________________
Nick Humphrey Download for free my experimental music, art, poetry and pictures. My album Classic E B-sides can be purchased on both itunes and amazon.com. Help me improve my phrasebook of world languages. I offer remote healing services. My blog. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|