Languages
[Edit]
EN

JavaScript - Math.min() method example

8 points
Created by:
Zayaan-Rasmussen
543

The Math.min() function returns the smallest number from given numbers.

Math.min() function usage with an array in ES5 and ES6 example:


1. Documentation

Edit
SyntaxMath.min(number1, number2, ...numbers)
Parametersnumber1, number2, ...numbers - integer or float number values (primitive values).
Result

Minimal number value (primitive value).

It returns Infinity if no arguments are passed.

It returns NaN if at least one of the provided values is not a number.

Descriptionmin is a static method that takes several arguments and returns the smallest value.

2. Getting min value from array examples

Edit

2.1. With Array reduce method example

Edit

This approach uses reduce method to find the minimum value inside an array. By making small modifications of Math.min(a, b) instruction we are able to find minimal value inside properties of a and b variables.

2.2. Recurrent min method example

Edit

This approach uses recurrence to find the minimum value inside the array or nested arrays.

References

Edit
  1. Maxima and minima - Wikipedia

 

Post thumbnail - JavaScript - Math.min() method example - link https://dirask.com/q/5D6ZZD

 

Alternative titles

  1. JavaScript - Math.min() documentation with examples
  2. js - Math.min() method documentation with examples
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

JavaScript - Math documentation (EN)

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join