Using Array.prototype - (sort is similar to what was posted by @katsPaugh and @deceze while I was doing a fiddle)
var arr = [
"2 --",
"3 ---",
"4 ----",
"1 -",
"5 -----"
];
Array.prototype.longest=function() {
return this.sort(
function(a,b) {
if (a.length > b.length) return -1;
if (a.length < b.length) return 1;
return 0
}
)[0];
}
alert(arr.longest());