Get the Min Value of an Array with JavaScript

02/07/2022
Contents
In this article, you will learn how to get the min value of an array with JavaScript.
The Math.min() method
If you specify multiple numbers as arguments, the Math.min() method returns the minimum value among them.
The syntax is below.
Math.min(num1,num2,num3,...)
To get the min value of the array that stores the numerical value, it is as follows.
Math.min.apply(null,array)
Get the Min Value of an Array
Below is the sample code to get the minimum value of the array.
console.log(Math.min(2, 5, 3)); // 2
console.log(Math.min(-2, -5, -3)); // -5
const array=[3,6,2,9,7];
console.log(Math.min.apply(null,array)); // 2