How to find the minimum value in an array in JavaScript

Finding the minimum value in numeric arrays is crucial for data validation, setting lower bounds, calculating ranges, and implementing features like price filters or threshold alerts in JavaScript applications. With over 25 years of experience in software development and as the creator of CoreUI, I’ve implemented minimum value calculations in components like slider controls, budget trackers, and validation systems where identifying the lowest values ensures proper data boundaries. From my extensive expertise, the most elegant and efficient solution is using Math.min() combined with the spread operator to find the smallest number. This approach is concise, performant, and utilizes JavaScript’s built-in mathematical functions for reliable results.

Use Math.min() with the spread operator to find the smallest value in an array.

const numbers = [3, 7, 2, 9, 1, 5]
const minimum = Math.min(...numbers)
// Result: 1

The Math.min() function finds the smallest of the provided arguments, and the spread operator ... expands the array elements as individual arguments to the function. In this example, Math.min(...numbers) is equivalent to Math.min(3, 7, 2, 9, 1, 5), which returns 1 as the smallest value. This method only works with numeric arrays and will return NaN if any element cannot be converted to a number. For empty arrays, it returns Infinity.

Best Practice Note:

This is the same approach we use in CoreUI components for setting minimum scale values in charts and establishing lower bounds in form validation across our component library. For arrays with non-numeric values, filter first: Math.min(...array.filter(Number)). For very large arrays (>100k elements), consider using a traditional loop to avoid stack overflow issues. For objects, use: Math.min(...array.map(item => item.value)).


Speed up your responsive apps and websites with fully-featured, ready-to-use open-source admin panel templates—free to use and built for efficiency.


About the Author