Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

find duplicates in array

function findDuplicates(arr) {
	const duplicates = new Set()
  
  return arr.filter(item => {
  	if (duplicates.has(item)) {
    	return true
    }
    duplicates.add(item)
    return false
  })
}
Source by flaviocopes.com #
 
PREVIOUS NEXT
Tagged: #find #duplicates #array
ADD COMMENT
Topic
Name
5+7 =