linq.js
function firstOrDefault(predicate, defaultValue) {
  predicate = typeof predicate === 'function' ? predicate : util.defaultPredicate;

  for (let item of this) {
    if (predicate(item)) return item;
  }

  return defaultValue;
}
function firstOrDefault(predicate, defaultValue) {
  predicate = typeof predicate === 'function' ? predicate : util.defaultPredicate;

  for (let item of this) {
    if (predicate(item)) return item;
  }

  return defaultValue;
}
function firstOrDefault ( predicate , defaultValue ) { predicate = typeof predicate === 'function' ? predicate : util . defaultPredicate ; for ( let item of this ) { if ( predicate ( item ) ) return item ; } return defaultValue ; }
Returns the first element of the sequence that satisfies a condition or a default value if no such element is found.

@param {(Function)} predicate The function called per iteraction till returns true.
@param defaultValue The default value.
Returns the first element of the sequence that satisfies a condition or a default value if no such element is found .