does GetPropertyNames() preserve property order

Go To


If we have this javascript code: var obj = { b:{propb: 10}, d: {propd: 15}, c: {propc: 15}, a: {propa: 5} }

Does v8::Object::GetPropertyNames() guarantee that the property names will be returned in the same order as they were defined above? I did a test, and the order is preserved, but I want to know if this is guaranteed.

2012-04-04 17:13
by Alexander Vassilev


Specification 5.1 of ECMA-262: "The mechanics and order of enumerating the properties [...] is not specified."

For v8 the order of enumerating the properties is currently also unspecified. It might work in some cases, but better don't rely on it.

Chromium ticket about v8 ordering:

2012-04-14 22:31
by Skomski