Last active
September 6, 2024 02:29
-
-
Save steveast/c4b07807db8a83046ef81c8b0476bde4 to your computer and use it in GitHub Desktop.
Собеседование: Отфильтровать объекты от повторяющихся значении.
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
const array1 = [{ | |
"id": 1, | |
"name": "apple", | |
}, { | |
"id": 2, | |
"name": "orange" | |
}]; | |
const array2 = [{ | |
"id": 1, | |
"name": "apple", | |
}, { | |
"id": 4, | |
"name": "purple" | |
}]; | |
const unique = array1.concat(array2).filter((cursor, index, source) => ( | |
source.map(record => record['id']).indexOf(cursor['id']) === index | |
)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment