mapField
Returns a new array with elements transformed by extracting a specific field.
mapField
Returns a new array with elements transformed by extracting a specific field.
Type: transform
Parameters
- input (array): The input array of objects to extract fields from.
- field (string): The field name to extract from each object.
Returns
Type: array
A new array with extracted field values, or empty array if input is not an array.
Examples
mapField([{name: "John"}, {name: "Jane"}], "name") // ["John", "Jane"]
[{age: 30}, {age: 25}]|mapField("age") // [30, 25]
mapField([{x: 1, y: 2}, {x: 3, y: 4}], "x") // [1, 3]
map
Returns an array containing the results of applying the expression parameter to each value in the array parameter.
reduce
Returns an aggregated value derived from applying the function parameter successively to each value in array in combination with the result of the previous application of the function.