For example, if my array is multi-dimensional:
var myArray = [
{
key1: {
key2: 1,
...
},
...
},
{
key1: {
key2: 2,
...
},
...
}
];
myArray.map('key1').sum('key2');
= 3
This could also be
myArray.map('key1').map('key2').sum();
but is there a way to combine them into one call to map?
When map takes a string it is effectively a shortcut for pluck.
As described in the Sugar documentation, map can more traditionally take a function as well:
Therefore: