The unique()
function will return a list of the unique values from the original list. It acts as a de-duplication function.
unique(list)
list.unique()
Code language: JavaScript (javascript)
Example Formulas
[1, 1, 2, 3, 2, 5].unique()
/* Output: [1, 2, 3, 5]
Code language: Java (java)
unique()
is case-sensitive, so you may want to run a list through another function first in order to get all elements in a consistent case:
["Zangief", "zangief", "ZANGIEF"].unique()
/* Output: ["Zangief", "zangief", "ZANGIEF"] */
["Zangief", "zangief", "ZANGIEF"].map(
current.lower()
).unique()
/* Output: ["zangief"]
Code language: JavaScript (javascript)