In this article, you’ll learn how to find the min and max elements in an array in javascript. There are various methods to find the smallest and largest numbers in a JavaScript array. JavaScript Math class offers the max() and min() functions, which return the largest and the smallest value among the given numbers, respectively. You can use these methods to find the maximum and minimum in an array.

Here are some examples to find the min and max elements in an array in javascript.

Example 1: Using Spread Operator with Math.max() and Math.min()

In this example, we used the spread(...) operator with the Math.max() and Math.min() for regular arrays:

Example 1: Using Spread Operator with Math.max() and Math.min()

Example 2: apply() function with Math.max() and Math.min()

In this example, we used the Function.prototype.apply() method. For arrays with fewer elements, you can use the Function.prototype.apply() method to find the maximum and minimum value in a numeric array.

Example 2: apply() function with Math.max() and Math.min()

Example 3: reduce() function with Math.max() and Math.min()

In this example, we used the Array.reduce() method. The approach is recommended to use the Array.reduce() to find the max and min elements in an array. This approach works by comparing each value of the array:

Example 3: reduce() function with Math.max() and Math.min()

## Comments