Object.map

Object.map

Object.map

Function

Iterate over the object and write the callback return value to the new object.

Syntax

Parameters

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

Return value

TypeDescription
ObjectReturns the new object after mapping.

Return object fields

The returned object uses the field names of the original object, and each field value is the callback return value. When the callback does not return a natural value, the field value is empty.

Example

Notes

  • The returned object retains the original key name.
  • The original object will not be modified.