Property Iteration in JSON serialization

Maciej Stachowiak mjs at
Wed Oct 14 22:53:22 PDT 2009

On Oct 14, 2009, at 10:47 PM, Maciej Stachowiak wrote:

> (*) - If you use constructor functions to make an object with  
> properties named (x, y, z) added in that order, with a prototype  
> that has properties (a, b, c), and in turn has a prototype with  
> properties (q, r, s), JSC and SpiderMonkey report "x y z a b c q r  
> s" but V8 gives "x z y a c b q r s". I'm not sure what rule would  
> give that output. I'm not even sure if this behavior is intentional  
> or a bug.

Correction: on further testing, it appears that Chrome's ordering  
anomaly is for own properties added by a constructor function, whether  
or not there's a prototype with enumerable properties. Chrome reports  
"a c b" for the following, whereas other browser which reports "a b c".

function Construct()
     this.a = "a";
     this.b = "b";
     this.c = "c";

var constrObj = new Construct();

function printProperties(description, o) {
     document.write(description + ":");
     for (var pname in o) {
         document.write(" " + pname);

printProperties("constructed object", constrObj);

More information about the es-discuss mailing list