Created
May 28, 2020 09:03
-
-
Save ERPedersen/5f90f967e4d5e8e48ffe4c580d7fe3b4 to your computer and use it in GitHub Desktop.
ES6 Unique Arrays
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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