The example of min_by in the documentation has the following example:

a = %w(albatross dog horse) a.min_by {|x| x.length } #=> "dog"

So we can roughly translate that to JavaScript as:

var arr = ['albatross', 'dog', 'horse']; function minBy(arr) { var result = arr.map(function (el) { return el.length; }); var min = Math.min.apply(null, result); return arr[result.indexOf(min)]; } minBy(arr); // dog

max_by would use Math.max.apply instead.

function maxBy(arr) { var result = arr.map(function (el) { return el.length; }); var min = Math.max.apply(null, result); return arr[result.indexOf(min)]; } maxBy(arr); // albatross

You could also amend the array prototype to get it more Rubyish.

if (!('minBy' in Array.prototype)) { Array.prototype.minBy = function (type) { var result = this.map(function (el) { return el[type]; }); var min = Math.min.apply(null, result); return arr[result.indexOf(min)]; }; } arr.minBy('length'); // dog

DEMO