Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to remove duplicates in js array

let arr = [1, 2, 3, 4, 3, 3, 3]

console.log([...new Set(arr)])
// (4) [1, 2, 3, 4]

let arr = [1, 2, 3, 4, 3, 3, 3, 'foo', true]

console.log([...new Set(arr)])
//(6) [1, 2, 3, 4, 'foo', true]
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #remove #duplicates #js #array
ADD COMMENT
Topic
Name
8+2 =