To find the largest number contained in a JavaScript array, we use the Math.max
method and the spread operator.
For instance, we write
const arr = [1, 2, 3];
const max = Math.max(...arr);
to call Math.max
with the entries in the arr
array as arguments.
We use the spread operator to spread the entries as arguments.