Last active
July 11, 2017 09:01
-
-
Save SergProduction/3935b07a57b7b145d00aa13b39e06610 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
const arr = [ | |
{ val: 'A' }, | |
{ val: 'B' }, | |
{ val: 'C' }, | |
{ val: 'B' }, | |
{ val: 'D' }, | |
{ val: 'C' }, | |
{ val: 'B' }, | |
{ val: 'D' }, | |
{ val: 'C' }, | |
{ val: 'B' }, | |
{ val: 'D' }, | |
{ val: 'C' }, | |
{ val: 'X' }, | |
{ val: 'A' }, | |
]; | |
const filtered = arr.reduce((acc, arrItem) => { | |
acc[arrItem.val] = arrItem | |
return acc | |
}, {}) | |
const res = Object.values(filtered) | |
console.log(res); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment