unique

This function returns a new list where each item in the list is unique. If duplicated items are found, the first item will be retained.

An item in the list is marked as a duplicate when an item is compared as equal to another item using the == operator.

This function does not generate a change.

Function

list.unique()

Arguments

None

Return value

Returns a new list where each item in the list is unique. The original list stays untouched.

Example

This code shows an example of unique():

["tic", "tac", "tic", "toe"].unique();  // the second `tic` will not be retained in the new list

Return value in JSON format

[
    "tic",
    "tac",
    "toe"
]