Last active
December 12, 2021 07:14
-
-
Save sererejegede/640fb4ecbfc803f81956b03a57d2fc2c to your computer and use it in GitHub Desktop.
Copy of this SO answer https://stackoverflow.com/a/64334282/9066443
This file contains 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
/** | |
* @param {Array} arr - Array to be filtered from | |
* @param {Array} props - array of keys that needs to be unique | |
* @returns {Array} - unique array | |
*/ | |
const unique = (arr, props = []) => [...new Map(arr.map(entry => [props.map(k => entry[k]).join('|'), entry])).values()] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment