Object object operation
Object object operation
Function
The Object prototype function provides key-value enumeration, JSON stringification, deep copy, merge, filter, clipping and high-order traversal capabilities.
API List
| API | Description |
|---|---|
| Object.len | Returns the number of key-value pairs of the object itself. |
| Object.to_string | Serialize an object to a JSON string. |
| Object.keys | Returns an array of object key names. |
| Object.values | Returns an array of object values. |
| Object.entries | Returns an array of entries in the form [key, value]. |
| Object.reverse | Returns a new object with the key order reversed. |
| Object.concat | Consolidate one or more objects into a new object. |
| Object.clone | Returns a deep copy of the object. |
| Object.delete | Delete the specified key. |
| Object.has_key | Determine whether the specified key exists in the object. |
| Object.get | Read the specified key and return the default value if missing. |
| Object.is_empty | Determine whether the object is empty. |
| Object.from_entries | Create an object from an array of [key, value] entries. |
| Object.each | Traverse object key values and execute callbacks. |
| Object.map | Traverse the object and write the callback return value into the new object. |
| Object.filter | Filter the key-value pairs that make the callback result true. |
| Object.every | Determine whether all key-value pairs make the callback result true. |
| Object.some | Determine whether there is a key-value pair for the callback result to be true. |
| Object.find | Returns the first value that makes the callback result true. |
| Object.find_key | Returns the first key for which the callback result is true. |
| Object.update | Merge one or more objects into the current object in place. |
| Object.pick | Select a field by key name and return a new object. |
| Object.omit | Exclude fields by keyname and return a new object. |
| Object.clear | Clear the object and return the original object. |
Examples
user = {name: 'BT', age: 1} result = user.keys() // Output: ["name","age"] print result
Notes
- Objects maintain insertion order.
- clone, reverse, concat, map, filter, pick, omit, from_entries return new objects; delete, update, clear will modify the original object.