Skip to content

Instantly share code, notes, and snippets.

@rebelnz
Created February 20, 2019 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rebelnz/54d211202480745b99caea88d0358b60 to your computer and use it in GitHub Desktop.
Save rebelnz/54d211202480745b99caea88d0358b60 to your computer and use it in GitHub Desktop.
const officers = [
{id: 1, name: 'Cpt Brown', country: 'NZ'},
{id: 2, name: 'Lt Fredrick', country: 'USA'},
{id: 3, name: 'Sgt Deaken', country: 'NZ'},
{id: 4, name: 'Lt Smoller', country: 'CAN'},
{id: 5, name: 'Cpt Kincaid', country: 'USA'}
]
// var ids = officers.map(function(o) {
// return o.id
// })
const ids = officers.map((o) => {
return o.id
})
@rebelnz
Copy link
Author

rebelnz commented Feb 20, 2019

map and arrow function

@rebelnz
Copy link
Author

rebelnz commented Feb 20, 2019

const ids = officers.map(o => o.id)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment