DEV Community

Discussion on: 1 line of code: How to get highest numeric item of an Array

 
jrop profile image
Jonathan Apodaca

And unsurprisingly, this is even faster:

let m = Number.NEGATIVE_INFINITY;
for (const x of data) {
  m = Math.max(x, m);
}
Enter fullscreen mode Exit fullscreen mode