indexBy_.indexBy(list, iteratee, [context])
Given a list, and an iteratee function that returns a key for each element in the list (or a property name), returns an object with an index of each item. Just like groupBy, but for when you know your keys are unique.
1 2 3 4 5 6 7 | var stooges = [{name: 'moe' , age: 40}, {name: 'larry' , age: 50}, {name: 'curly' , age: 60}]; _.indexBy(stooges, 'age' ); => { "40" : {name: 'moe' , age: 40}, "50" : {name: 'larry' , age: 50}, "60" : {name: 'curly' , age: 60} } |
Please login to continue.