Skip to content

Commit

Permalink
Normative: Use array indices instead of integer indices in OrdinaryOw…
Browse files Browse the repository at this point in the history
…nPropertyKeys (#1242)

All major JavaScript engines agree on the following behavior:

    $ eshost -e 'Reflect.ownKeys({ a: 1, [Number.MAX_SAFE_INTEGER]: 1, 42: 1, [2**32-1]: 1, [2**32-2]: 1 })'

    #### Chakra
    42,4294967294,a,9007199254740991,4294967295

    #### V8 --harmony
    42,4294967294,a,9007199254740991,4294967295

    #### V8
    42,4294967294,a,9007199254740991,4294967295

    #### JavaScriptCore
    42,4294967294,a,9007199254740991,4294967295

    #### SpiderMonkey
    42,4294967294,a,9007199254740991,4294967295

That is, the order is:

- array indices, in ascending numeric index order
- strings that are not array indices, in ascending chronological creation order
- symbols, in ascending chronological creation order

This patch makes the spec for `OrdinaryOwnPropertyKeys` match Web reality.
  • Loading branch information
mathiasbynens authored and bterlson committed Oct 24, 2018
1 parent f47d5d5 commit 9da8fb6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -7070,9 +7070,9 @@ <h1>OrdinaryOwnPropertyKeys ( _O_ )</h1>

<emu-alg>
1. Let _keys_ be a new empty List.
1. For each own property key _P_ of _O_ that is an integer index, in ascending numeric index order, do
1. For each own property key _P_ of _O_ that is an array index, in ascending numeric index order, do
1. Add _P_ as the last element of _keys_.
1. For each own property key _P_ of _O_ that is a String but is not an integer index, in ascending chronological order of property creation, do
1. For each own property key _P_ of _O_ that is a String but is not an array index, in ascending chronological order of property creation, do
1. Add _P_ as the last element of _keys_.
1. For each own property key _P_ of _O_ that is a Symbol, in ascending chronological order of property creation, do
1. Add _P_ as the last element of _keys_.
Expand Down

0 comments on commit 9da8fb6

Please sign in to comment.