Comment #117 on issue 164 by [email protected]: Wrong order in Object properties interation
http://code.google.com/p/v8/issues/detail?id=164

Its not necessarily bad coding to want your key value pairs reserved. Consider the example of displaying data in a grid where you expect rows to be in order via their primary key from the database. Because we have the elegance of associative arrays where our keys can be meaningful, we SHOULD be able to utilize those keys in the code. So you create a bunch of data on the server side and create a JSON object out those rows KEYED by their primary keys in the database. Instead of having the primary key be a property of each object. So you SHOULD be able to loop through my rows and they should be in the same order as they were when i created the JSON object. However, because the keys are not preserved, in Chrome this doesn't happen.

So i have 2 solutions. Either add the _ and substr(1) it out later. Or don't use the primary key as the key to my associative array. Which isn't a good solution in my head because that makes the data read correctly, and its a very nice elegant solution when looping. While looping your key is your row id, and your value is an object of the data. Done deal.

Its not bad coding to want your keys to be meaningful.

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to