Author: Not specified Language: javascript
Description: Not specified Timestamp: 2018-04-17 08:51:08 +0000
View raw paste Reply
  1. _.reduce([1, 2], function(sum, n) {
  2.   return sum + n;
  3. }, 0);
  4. // => 3
  5.  
  6. _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  7.   (result[value] || (result[value] = [])).push(key);
  8.   return result;
  9. }, {});
  10. // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
View raw paste Reply