Skip to content

Enumeration order incorrect with deletes #4486

@bterlson

Description

@bterlson
let obj = {x: 1, y: 2};
obj.p1 = 1;
obj.p2 = 2;
delete obj.p1;
obj.p1 = 1;

let str = '';
for (prop in obj) {
    str += '<' + prop + '> ';
}

print(str);

┌─────────────────────┬───────────────────┐
│ Chakra              │ <x> <y> <p1> <p2> │
├─────────────────────┼───────────────────┤
│ JavaScriptCore      │ <x> <y> <p2> <p1> │
│ SpiderMonkey        │                   │
│ V8                  │                   │
└─────────────────────┴───────────────────┘

JSC, SM, and V8 have the proper behavior here. The spec requires that own properties are enumerated in order of creation. In the example above, p1 is the last property created and so should be last (the fact that it existed before is not relevant).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions