RobG wrote:
> In other words, you can't depend on the properties of an object being
> returned in any particular order for different browsers.  You might
> like to get the names (say using for..in) and push them in an array,
> use Array.prototype.sort() to sort them, then use that order to get
> the property values.
>
> ...
Very helpful.  I think that is what I was missing.

Thanks,

Ken


var foodsByLetter = {
  'B': ['broccoli', 'bread'],
  'C': ['carrots', 'celery'],
  'A': ['alfalfa sprouts', 'apple']
};

Instead of:
for( var letter in foodsByLetter ) {
  // out of order
  foodsByLetter[letter];
}

I can do:
Object.keys(foodsByLetter).sort().each(function(letter) {
  foodsByLetter[letter];
});

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to