Skip to content

Instantly share code, notes, and snippets.

@blemoine
Last active April 5, 2017 18:23
Show Gist options
  • Save blemoine/65d716c005ea11268495274541e6fd08 to your computer and use it in GitHub Desktop.
Save blemoine/65d716c005ea11268495274541e6fd08 to your computer and use it in GitHub Desktop.
const user1= {firstName: "Georges", lastName: "Abitbol", age: 43}
const user2= {firstName: "Joel", lastName: "Hammond", age: 25}
// Classic way of writing a map
// Here TypeScript will know that the result is an Array<string>
_.map([user1, user2], user => user.firstName)
//Shortcut way of writing a map
//Previously known as the pluck function
//TypeScript could not infer the return type, and will be an Array<any>
_.map([user1, user2], 'firstName');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment