Finding longest string in array

Available since Javascript 1.8/ECMAScript 5 and available in most older browsers:

var longest = arr.reduce(
    function (a, b) {
        return a.length > b.length ? a : b;
    }
);

Otherwise, a safe alternative:

var longest = arr.sort(
    function (a, b) {
        return b.length - a.length;
    }
)[0];

A new answer to an old question: in ES6 you can do shorter:

Math.max(...(x.map(el => el.length)));