Find Minimummaximum Value Of An Array

JavaScript: Find Minimum and Maximum value of an Array

Before the ES5, we use the Math.max.apply() and Math.max.apply() function to find the minimum or maximum value of an array. But since the spread operator is released, we recommend using the Math.min() and Math.max() with spread operator to accomplish this.

This is because it will reduce redundancy by simplify your syntax. It may makes your code looks much cleaner and better.

const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9];

// Not Recommend
const min = Math.min.apply(null, numbers); 
const max = Math.max.apply(null, numbers); 

// Recommend
const min = Math.min(...numbers);
const max = Math.max(...numbers);

Further Readings