Possible Duplicate:
For..In loops in javascript - key value pairs
I need to loop through an array in order, just like in this question. However, I also need to get access to the key
name. How can I do that while in a numerically indexed loop?
for(i=0; i<arr.length; i++){
alert(arr[i].key); // clearly won't work
}
but
for(key in arr){
alert(arr[key]); // works, but it doesn't loop through in the right order
}