-
-
Save blemoine/65d716c005ea11268495274541e6fd08 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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