Policies & Guidelines

FIND_BY_KEY

Find an object in array by a key

Description

Finds an object in the given array by a key-value pair.

For example, given Key "id" and Value 123, will return the object in the array whose id property is 123, or null if such an object was not found.

If multiple matches exist, the first matching object is returned.

Function signature

FIND_BY_KEY(array: Array, key: String, value: ) => Object

Parameter

Description

Array

Array to find object in

Key

Key whose value to match

Value

Value to match

Examples

array1 = [{"a":3},{"a":2}]
key = "a"
value = 2
array = [{"a":3},{"a":{"b":10}}]
objValue = {"b":10}

Formula

Return value

FIND_BY_KEY(array1, key, value)

{"a":2}

FIND_BY_KEY(array, key, objValue)

{"a":{"b":10}}