xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andreas Neumann <neum...@karto.baug.ethz.ch>
Subject Re: Strange behaviour of Rhino with associative array object
Date Sat, 18 Oct 2003 17:55:59 GMT
> what you can do is:
> 
> a=[]
> a['chicken']=whatever
> a.push(a['chicken'])
> 
> for (i=0;i<a.length;i++) alert(a)

ok, got that - works fine so far. But is there a way, while using your above
described for-loop to get at the same time the key of the associative array
back, that is corresponding with the value?

f.e. if I use:

var fruits = new Array();
fruits["oranges"] = 25;
fruits.push(fruits["oranges"]);
fruits["bananas"] = 15;
fruits.push(fruits["bananas"]);
fruits["pineapples"] = 8;
fruits.push(fruits["pineapples"]);

for (i=0;i<fruits.length;i++) {
   alert(fruits[i]);
}

would give me the value of the fruits - how can I get back the key in the same
loop, to get the fruit to which the values is corresponding to.

Sorry to bother you again, I am still a beginner in Javascript.

Andreas


--     
The only thing that stands between a man and what he wants from
life is often merely the will to try it and the faith to believe
that it is possible ...
-- M. DeVos
    
----------------------------------------------     
Andreas Neumann - Department of Cartography     
Swiss Federal Institute of Technology (ETH)     
ETH Hoenggerberg, CH-8093  Zurich, Switzerland     
Phone: ++41-1-633 3031, Fax: ++41-1-633 1153     
e-mail: neumann@karto.baug.ethz.ch     
www: http://www.karto.ethz.ch/neumann/     
SVG.Open/Carto.net: http://www.svgopen.org/     

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Mime
View raw message