linq.js
function max(keySelector, comparer) {
  let itComparer = typeof comparer === 'function' ? comparer : util.defaultComparer;
  let itKeySelector = typeof keySelector === 'function' ? keySelector : (i) => i;

  let maximum = this.firstOrDefault();

  for (let item of this) {
    maximum = itComparer(itKeySelector(item), itKeySelector(maximum)) > 0 ? item : maximum;
  }

  return maximum;
}
function max(keySelector, comparer) {
  let itComparer = typeof comparer === 'function' ? comparer : util.defaultComparer;
  let itKeySelector = typeof keySelector === 'function' ? keySelector : (i) => i;

  let maximum = this.firstOrDefault();

  for (let item of this) {
    maximum = itComparer(itKeySelector(item), itKeySelector(maximum)) > 0 ? item : maximum;
  }

  return maximum;
}
function max ( keySelector , comparer ) { let itComparer = typeof comparer === 'function' ? comparer : util . defaultComparer ; let itKeySelector = typeof keySelector === 'function' ? keySelector : ( i ) => i ; let maximum = this . firstOrDefault ( ) ; for ( let item of this ) { maximum = itComparer ( itKeySelector ( item ) , itKeySelector ( maximum ) ) > 0 ? item : maximum ; } return maximum ; }
Returns the maximum value in a sequence.

@param keySelector A transform function to apply to each element.
@param comparer A comparer function to check with item is greater.
@return The maximum value in the sequence.
keySelector: (T) -> key
comparer: (item1, item2) -> -1|0|1
Returns the maximum value in a sequence .