Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

unique element in array

const unique = (value, index, self) => {
  return self.indexOf(value) === index
}

const ages = [26, 27, 26, 26, 28, 28, 29, 29, 30]
const uniqueAges = ages.filter(unique)
console.log(uniqueAges)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #unique #element #array
ADD COMMENT
Topic
Name
2+3 =