Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const a = [1, 3, 2, 4, 2, 4, 5] //1, 3, 5
- a.reduce((mapping, item, index, arr) => {
- mapping[item] = !!mapping[item] ? ++mapping[item] : 1
- return index === arr.length - 1 ? Object.keys(mapping).filter((e) => mapping[e] === 1) : mapping
- }, {})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement