Skip to content

findLastIndex

findLastIndex(array, predicate) → number · Array

Find the index of the LAST element matching a predicate, or -1 if not found.

  • array (required): the array to search

  • predicate (required): lambda (element) -> boolean

bash
echo '{"items": ["A", "B", "A", "C"]}' | utlx -e 'findLastIndex($input.items, (x) -> x == "A")'
# 2
utlx
{
  lastActive: findLastIndex($input.users, (u) -> u.active)
}

Released under AGPL-3.0.