- Instant help with your JavaScript coding problems

Get the minimum value in an array using JavaScript

Question:
How to get the minimum value in an array using JavaScript?
Answer:
const myArray = [4, -14, 32, 7];

const minValue = Math.min(...myArray);

console.log(minValue ); // -14
Description:

In modern JavaScript getting the minimum value in an array is quite simple by using the Math.min function and the spread ... operator.

The static function Math.min() returns the lowest-valued number passed into it, or NaN if any parameter isn't a number and can't be converted into one. The result is Infinity if no parameters are provided.

Reference:
Math.min reference
Share "How to get the minimum value in an array using JavaScript?"