Policies & Guidelines

IS_IN_ARRAY_BY_KEY

Is the given item (identified by a key-value pair) in the target array?

Description

Given an array of objects, the name of a key present in the objects, and a value to match, returns true if a matching item is found in the array, or false if it is not.

Function signature

IS_IN_ARRAY_BY_KEY(array: Array, key: String, value: ) => Boolean

Parameter

Description

Array

Array to find object in

Key

Key of object whose value to match

Value

Value to match

Examples

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

Formula

Return value

IS_IN_ARRAY_BY_KEY(array1, "a", 2)

true

IS_IN_ARRAY_BY_KEY(array2, "a", 2)

false

IS_IN_ARRAY_BY_KEY(array, "a", { b: 10 })

true