documentcloud/underscore — pull request #358 by Mottie (2011-11-01 04:09:16+00:00)
Title: Added allIndexOf

Returns all indexes of the element in the array. I made a [blog post](http://wowmotty.blogspot.com/2011/10/get-all-indexof-from-array.html) and a [jsFiddle demo](http://jsfiddle.net/Mottie/NneeH/2/embedded/result/) without using any library, but I thought it would be a nice addition to underscore :)

Use it as follows:

```javascript
var t = ["red","green","blue","red","yellow","blue","green","purple","red"];
_.allIndexOf( t, 'red'); // result [ 0,3,8 ]

var t = [0,1,2,3,4,5,6,7,4,2,6,7,11,12,4,7];
_.allIndexOf( t, "4" ); // result [ -1 ]
_.allIndexOf( t, 4 ); // result [ 4,8,14 ]
```

I made a [string version](http://wowmotty.blogspot.com/2011/10/get-all-indexof-search-string.html) of allIndexOf, but I wasn't sure if it would fit in this library. If you think it would also be a nice addition, I would be happy to add that as well.