Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to get duplicate values from array in javascript

let a = [1, 2, 3, 4, 2, 2, 4, 1, 5, 6]
let b = [...new Set(a.sort().filter((o, i) => o !== undefined && a[i + 1] !== undefined && o === a[i + 1]))]

// b is now [1, 2, 4]
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #duplicate #values #array #javascript
ADD COMMENT
Topic
Name
2+7 =