ES6 - Math min() Function



This method returns the smallest of zero or more numbers. If no arguments are given, the results is +Infinity.

Syntax

Math.min( x1,x2,… ) ;       

Parameter

  • X1,x2,x3.. − represents a series of numbers

Example

console.log("---Math.min()---") 
console.log("Math.min(1, 2) : "+Math.min(1, 2)) 
console.log("Math.min(3, 0.5, 0.66) : "+Math.min(3, 0.5, 0.66)) 
console.log("Math.min(3, 0.5, -0.66) : "+Math.min(3, 0.5, -0.66))          

Output

---Math.min()--- 
Math.min(1, 2) : 1 
Math.min(3, 0.5, 0.66) : 0.5 
Math.min(3, 0.5, -0.66) : -0.66        
Advertisements