ecmascript 6 - es6 Loop through object array and aggregate unique values from key pair (cleanest way) -


what's cleanest , es6 native (if possible) way loop through object array grab each unique value. example :

[{ "name" : "joe", }, ,{ "name" : "jean", }, { "name" : "joe", }, { "name" : "joe", }, { "name" : "mike",  }] 

and in results want see : joe, jean, mike (only unique values, no dupes)

since mentioned es6, seems set object want since uniqueness part , should efficiently:

var objs = [{"name" : "joe"},{"name" : "jean"},{"name" : "joe"},{"name" : "joe"},{"name" : "mike"}];    let uniquenames = array.from(new set(objs.map(item => item.name)));  console.log(uniquenames);

run snippet see results.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -