0

Possible Duplicate:
Loop through associative array in reverse

I have a key-value pair javascript object. How do I reverse() it? or loop it starting from the bottom. jQuery available.

Community
  • 1
  • 1
Moe Sweet
  • 3,683
  • 2
  • 34
  • 46

1 Answers1

2

There is no hard specification or guarantee of determining the order of properties in a Javascript object. Most browsers go from what was added first to last, but as Elements order in a "for (… in …)" loop describes, Chrome and Opera do not.

If order is important to you, then you must use an array, or have an array that lists the order in which the properties should be accessed when looping (from either direction).

Community
  • 1
  • 1
ima007
  • 467
  • 3
  • 12