how to get the longest string in javascript by sort method code example Example: javascript find the longest string in array Math.max(...(x.map(el => el.length)));