I have an array of objects in Javascript:
var List = [
{
employee:'Joe',
type:'holiday',
},
{
employee:'Jerry',
type:'seminar',
},
{
employee:'Joe',
type:'shore leave',
}
];
I would like to obtain two new arrays of objects; one for the key employee "Joe" and the other for the key employee "Jerry". The objects should keep the same pairs of key/values.
I have been trying to get a solution using underscore.js, but it is getting too complicated. Any ideas on how this can be achieved?
_.groupByand_.pluck, most likely."Joe"s. What do you want the result to look like?