i wanna find Non-duplicate element array in javascript with filter method. for example: const number = [1,2,1,3,4,5,3]; i wanna find 2,4,5 in array please help me
Asked
Active
Viewed 822 times
0
-
[Get all unique values in a JavaScript array (remove duplicates)](https://stackoverflow.com/q/1960473/3982562) – 3limin4t0r May 09 '20 at 17:36
1 Answers
0
Use this code snippet: number.filter(x => number.filter(y => x === y).length === 1)
Explanation
Filter out (outer filter) only those numbers from the array which occur (checked using inner filter) exactly once in the array.

Tuhin Karmakar
- 171
- 2
- 9