_.extend code example

Example 1: find element in array underscore js

console.log(_.find(response.data, function(item) {
    return item.TaskCategory.TaskCategoryId == $routeParams.TaskCategory; 
}));

Example 2: find max of countby

var array = [3, 'a', 'a', 'a', 2, 3, 'a', 3, 'a', 2, 4, 9, 3];

var result = _.head(_(array)
  .countBy()
  .entries()
  .maxBy(_.last));

console.log(result);

Example 3: underscore js join

_.reduce(['x', 'y', 'z'], function(accumulator, currentItem) {
    return accumulator + currentItem;
});
// xyz

Example 4: Underscore.js

var evens = _.filter([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; });
=> [2, 4, 6]