Skip to main content

.uniq()

A function that deduplicates adjacent elements from an array, while preserving the order of the remaining elements.

Similar to the *nix uniq command, duplicate values that are not adjacent are not removed.

Syntax

#fs.scripts.lib().uniq(array);

Parameters

array

The array to be deduplicated.

Return

Returns an array.

Example

function(context, args) {
const l = #fs.scripts.lib();
const my_array = ["apples", "apples", "bananas", "oranges", "apples", "limes"];

return l.uniq(my_array); // => ["apples", "bananas", "oranges", "apples", "limes"]
}