Say I have an array of arrays, and I want to return the first element of each array within the array:
array = [[["028A","028B","028C","028D","028E"],
["028F","0290","0291","0292","0293"],
["0294","0295","0296","0297","0298"],
["0299","029A","029B","029C","029D"],
["029E","029F","02A0","02A1","02A2"]],
[["02A3","02A4"],
["02A5", "02A6"]];
I know I can do something like this:
var firsts = [];
_.each(array, function(item){
_.each(item, function(thisitem){
firsts.push(_.first(thisitem));
});
});
but what if I want to do it with underscore's _.chain()
method? Just learning underscore, and so far seems very useful.
var first = function(a) { return _.first(a); };
– Liminal