The Math.min()
returns the lowest-valued number passed into it.
It returns NaN if any parameter can't be converted a number.
Math.min([value1[, value2[, ...]]]) // value1, value2, ... are numbers
If no arguments are given, the result is Infinity.
let x = 10, y = -20; let z = Math.min(x, y); console.log(z);//from ww w . j av a 2s.co m let min = Math.min(3, 54, 32, 16); console.log(min); // 3
The following code uses spread operator to get the minimum of an array:
var arr = [1, 2, 3]; var min = Math.min(...arr); console.log(min);/*from w w w .j a v a 2 s .c om*/