Author: Not specified Language: javascript
Description: Not specified Timestamp: 2018-04-17 10:27:45 +0000
View raw paste Reply
  1. var result = _.find(['a', 'b', 'c'], function (el, i, col) {
  2.  
  3.      // first argument is the current collection element 'a' - 'c'
  4.     console.log(el);
  5.  
  6.     // second argument is the current index 0 - 2
  7.     console.log(i);
  8.  
  9.     // third argument is the actual collection ['a','b','c']
  10.     console.log(col);
  11.  
  12.     // if true is returned, then that is what
  13.     // will be returned by _.find, else it will keep looking
  14.     return el === 'b'
  15.  
  16. });
  17.  
  18. console.log(result); // b
  19.  
  20.  
View raw paste Reply