JS: Order of Properties
Order of Properties
New in JS: ECMAScript 2020
Object's properties are kept in this order:
- Integer-like string keys, including
"0"
(aka Array index keys), In integer increasing order. - Other String keys, in creation order.
- Symbol keys, in creation order.
const xx = { 2: "x", b: "x", 1: "x", a: "x", 0: "x", "-1": "x", }; console.log(Object.keys(xx)); // [ "0", "1", "2", "b", "a", "-1" ] /* note. 0 1 2 etc are moved to front. -1 is not moved to front. Other string keys, stays in creation order. */
JavaScript, Property
- JS: Property Overview
- JS: Order of Properties
- JS: Property Key
- JS: Property Dot Notation vs Bracket Notation
- JS: Create Property
- JS: Delete Property
- JS: Get Set Property
- JS: Check Property Existence
- JS: Access Property
- JS: List Properties
- JS: for-in Loop 👎
- JS: Enumerable Property
- JS: Property Attributes
- JS: Property Descriptor
- JS: Getter Setter Properties