Object.reverse
Object.reverse
Function
Returns a new object with the key order reversed.
Syntax
object.reverse()
Parameters
No parameters.
Return value
| Type | Description |
|---|---|
| Object | Returns the new object value. |
Return object fields
The returned object contains all outer fields of the original object, the field values maintain the original runtime reference semantics, and only the field insertion order is reversed.
Example
user = {name: 'BT', age: 1} result = user.reverse().keys() // Output: ["age","name"] print result
Notes
- reverse does not modify the original object.
- reverse only reverses the outer key order, and the value itself maintains runtime reference semantics; you can continue to call clone when independent data is needed.