Object object operation

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

APIDescription
Object.lenReturns the number of key-value pairs of the object itself.
Object.to_stringSerialize an object to a JSON string.
Object.keysReturns an array of object key names.
Object.valuesReturns an array of object values.
Object.entriesReturns an array of entries in the form [key, value].
Object.reverseReturns a new object with the key order reversed.
Object.concatConsolidate one or more objects into a new object.
Object.cloneReturns a deep copy of the object.
Object.deleteDelete the specified key.
Object.has_keyDetermine whether the specified key exists in the object.
Object.getRead the specified key and return the default value if missing.
Object.is_emptyDetermine whether the object is empty.
Object.from_entriesCreate an object from an array of [key, value] entries.
Object.eachTraverse object key values and execute callbacks.
Object.mapTraverse the object and write the callback return value into the new object.
Object.filterFilter the key-value pairs that make the callback result true.
Object.everyDetermine whether all key-value pairs make the callback result true.
Object.someDetermine whether there is a key-value pair for the callback result to be true.
Object.findReturns the first value that makes the callback result true.
Object.find_keyReturns the first key for which the callback result is true.
Object.updateMerge one or more objects into the current object in place.
Object.pickSelect a field by key name and return a new object.
Object.omitExclude fields by keyname and return a new object.
Object.clearClear the object and return the original object.

Examples

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.