Object.each

Object.each

Object.each

Function

Iterate through object key values and execute callbacks.

Syntax

Parameters

ParametersTypeRequiredDefault valueDescription
callbackFnNoEmptyThe callback signature is fn(value, key, current).

Return value

TypeDescription
ObjectReturns the original object to facilitate continued chain calls.

Return object fields

each() returns the same object reference that it was called on. Field names and values retain the actual state of the original object at the end of the call; fields added, modified, or deleted during the callback will be reflected in the returned object.

Example

Notes

  • A shallow copy of the current content of the object is used during traversal. Callback modifications to the object will not affect the traversed items that have been taken out in this round.