Skip to content

Instantly share code, notes, and snippets.

@ERPedersen
Created May 28, 2020 09:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ERPedersen/5f90f967e4d5e8e48ffe4c580d7fe3b4 to your computer and use it in GitHub Desktop.
Save ERPedersen/5f90f967e4d5e8e48ffe4c580d7fe3b4 to your computer and use it in GitHub Desktop.
ES6 Unique Arrays
/*
* Returns an array of unique values from the provided array.
*
* @param input {array} Array of values
* @returns {array} Array of unique values
*/
const unique = (input) => [...new Set(input)];
unique([1, 1, 2, 2, 3, 4]); // => [1, 2, 3, 4]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment