Skip to content

first

first(array) → element or null · Array

Returns the first element of an array, or null if the array is empty.

  • array (required): the source array
utlx
first(["Apple", "Banana", "Cherry"])     // "Apple"
first([42])                              // 42
first([])                                // null

// Use case: get the cheapest product
{
  cheapest: first(sortBy($input.products, (p) -> p.price))
}

Released under AGPL-3.0.