1 // Copyright (C) 2018 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
4 esid: sec-ordinaryownpropertykeys
6 Returns keys in their corresponding order.
8 26.1.11 Reflect.ownKeys ( target )
11 2. Let keys be target.[[OwnPropertyKeys]]().
12 3. ReturnIfAbrupt(keys).
13 4. Return CreateArrayFromList(keys).
15 9.1.12 [[OwnPropertyKeys]] ( )
17 1. Let keys be a new empty List.
18 2. For each own property key P of O that is an array index, in ascending
20 a. Add P as the last element of keys.
21 3. For each own property key P of O that is a String but is not an array
22 index, in property creation order
23 a. Add P as the last element of keys.
24 4. For each own property key P of O that is a Symbol, in property creation
26 a. Add P as the last element of keys.
28 features: [computed-property-names, Reflect, Symbol]
36 [Number.MAX_SAFE_INTEGER]: true,
37 [Symbol.for('z')]: true,
43 var result = Reflect.ownKeys(o1);
45 assert.sameValue(result.length, 9);
46 assert.sameValue(result[0], '1');
47 assert.sameValue(result[1], '4294967294');
48 assert.sameValue(result[2], '12345678900');
49 assert.sameValue(result[3], 'b');
50 assert.sameValue(result[4], 'a');
51 assert.sameValue(result[5], String(Number.MAX_SAFE_INTEGER));
52 assert.sameValue(result[6], '12345678901');
53 assert.sameValue(result[7], '4294967295');
54 assert.sameValue(result[8], Symbol.for('z'));
58 o2[12345678900] = true;
62 o2[Number.MAX_SAFE_INTEGER] = true;
63 o2[Symbol.for('z')] = true;
64 o2[12345678901] = true;
65 o2[4294967294] = true;
66 o2[4294967295] = true;
69 result = Reflect.ownKeys(o2);
71 assert.sameValue(result.length, 9);
72 assert.sameValue(result[0], '1');
73 assert.sameValue(result[1], '4294967294');
74 assert.sameValue(result[2], '12345678900');
75 assert.sameValue(result[3], 'b');
76 assert.sameValue(result[4], 'a');
77 assert.sameValue(result[5], String(Number.MAX_SAFE_INTEGER));
78 assert.sameValue(result[6], '12345678901');
79 assert.sameValue(result[7], '4294967295');
80 assert.sameValue(result[8], Symbol.for('z'));