I’m sure it’s somewhere inside the LoDash docs, but I can’t seem to find the right combination.

var users = [{
      id: 12,
      name: 'Adam'
   },{
      id: 14,
      name: 'Bob'
   },{
      id: 16,
      name: 'Charlie'
   },{
      id: 18,
      name: 'David'
   }
]

// how do I get [12, 14, 16, 18]
var userIds = _.map(users, _.pick('id'));

8 Answers
8

Leave a Reply

Your email address will not be published. Required fields are marked *