Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript map return array with distinc values

//ES6
let array = [
  { "name": "Joe", "age": 17 },
  { "name": "Bob", "age": 17 },
  { "name": "Carl", "age": 35 }
];
array.map(item => item.age)
  .filter((value, index, self) => self.indexOf(value) === index)

> [17, 35]
Comment

PREVIOUS NEXT
Code Example
Javascript :: jspdf addimage 
Javascript :: js remove quotes from string 
Javascript :: angular find value in json array 
Javascript :: node.js mysql create table 
Javascript :: js loop through object 
Javascript :: unordered list in react native 
Javascript :: js contains class 
Javascript :: javascript find object by property in array 
Javascript :: change version of node mac 
Javascript :: Error: Node Sass version 5.0.0 is incompatible with ^4.0 
Javascript :: .map for object javscript 
Javascript :: set timer jquery 
Javascript :: top-level code javascript 
Javascript :: how to select data attribute in javascript using queryselectorAll 
Javascript :: javascript number to number with commas 
Javascript :: loop through list js 
Javascript :: model schema mongoose 
Javascript :: effect jquery 
Javascript :: js clear local storage 
Javascript :: how to pronounce allele 
Javascript :: how to make my website source file not accessible in inspectot 
Javascript :: how to clamp a value by modulus 
Javascript :: strtotime in javascript 
Javascript :: next js tailwind 
Javascript :: remove falsy value javascript 
Javascript :: npm windows shocut 
Javascript :: how to get current day in javascript 
Javascript :: lodash delete object property 
Javascript :: react-native-checkbox in a loop 
Javascript :: disable back button in react native 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =