JavaScript Math.max() | Find Largest Number

The JavaScript Math.max() method returns the largest number from given list of numbers. For example:

HTML with JavaScript Code
<!DOCTYPE html>
<html>
<body>

   <p id="xyz"></p>
 
   <script>
      let largeNum = Math.max(12, 43, 54, 10, 4);
      document.getElementById("xyz").innerHTML = largeNum;
   </script>
   
</body>
</html>
Output

JavaScript Math.max() Syntax

The syntax of Math.max() method in JavaScript is:

Math.max(n1, n2, n3, ..., nN)

n1, n2, n3 and so on, are all refers to numbers. All parameters are optional.

The Math.max() method returns a number with highest value. Also if no arguments are passed or provided to Math.max() method, it will return Infinity. Otherwise will return NaN if one or multiple arguments are not a number.

JavaScript Online Test


« Previous Tutorial Next Tutorial »



Like/Share Us on Facebook 😋