Powered By GitBook
UNIQUE_BY_KEY
Find unique objects by a key

Description

Returns the original list where any object duplicates by the given key are removed.
For example, given a list of objects and Key id, would return an array where items that have duplicate id property values are removed.
The object with the first unique value is always picked into the returned array, with subsequent occurences of the same value treated as duplicates and discarded.

Function signature

1
UNIQUE_BY_KEY(list: Array, key: String) => Array
Copied!
Parameter
Description
List
List to find objects
Key
Key for compare

Examples

1
array1 = [{"a":3},{"a":2},{"a":2,"b":3},{"a":2,"b":5}]
2
key = "a"
3
array2 = [{"a":{"b":20}},{"a":{"b":10}},{"a":{"b":10}}]
Copied!
Formula
Return value
UNIQUE_BY_KEY(array1, key)
[{"a":3},{"a":2}]
UNIQUE_BY_KEY(array2, key)
[{"a":{"b":20}},{"a":{"b":10}}]
Last modified 11mo ago
Export as PDF
Copy link