bestiejs/lodash — pull request #142 by danheberden (2012-12-18 18:19:38+00:00)
Title: add `grab` method to use an array to get elements from a collection

Example:

```javascript
var source = [ 'a', 'b', 'c', 'd', 'e', 'f', 'g' ];
_.grab( source, [1, 3] );
// => [ 'b', 'd' ]

var collection = [
{ name: 'John', github: 'jdalton' },
{ name: 'Mathias', github: 'mathiasbynens' },
{ name: 'Kit', github: 'kitcambridge' }
];
_.grab( collection, [0, 2] );
// => [
// { name: { name: 'John', github: 'jdalton' },
// { name: 'Kit', github: 'kitcambridge' }
// ];
// (sorry Mathias)
```

### What This Does

Gives you a new array of elements from the array/collection matching the indexes provided.

### Why I Made This

I've had this come up a few times in applications, namely when using collections as a data-source. In my latest situation, I have a collection that is the data-source for a slick-grid. When getting the selected rows, an array of which rows (e.g., `[3,5,6,7,9]`) is returned. Since lodash has so many other convenient methods to access arrays and collections, this seemed quite sensible to be able to `_.grab( collection, rows )`.

I also think some nifty stuff could be done by combining _.range with this.