To obtain smallest value from array in JavaScript, we use the Math.min
method.
For instance, we write
const arr = [14, 58, 20, 77, 66, 82, 42, 67, 42, 4];
const min = Math.min(...arr);
to call Math.min
with the entries in the arr
array as arguments to get the min number from the arr
array and return it.
We use the spread operator to spread the arr
values as arguments.