Created
February 11, 2022 11:21
-
-
Save chkilel/dd69044b2f6c795d8ffecc7678f81231 to your computer and use it in GitHub Desktop.
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
// Concat two arrays of objects and keep unique values | |
// Values from arr1 will be kept if exist in arr2, comparison made on `key` | |
// object {key: 1, label: '..', ....} | |
const unique = [...arr1, ...arr2].filter( | |
(item, index, self) => self.findIndex((t) => t.key === item.key) === index | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment