JavaScript Math max() method

The JavaScript math max() method is used to get the maximum value from a set of numbers.
Syntax:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Math.max(n1,n2,...)
Math.max(n1,n2,...)
Math.max(n1,n2,...)

Parameters
n1,n2,…: It represents the set of numbers.

Returns
Maximum value from a set of numbers.

Example:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<!DOCTYPE html>
<html>
<body>
<script>
document.writeln(Math.abs(-345));
</script>
</body>
</html>
<!DOCTYPE html> <html> <body> <script> document.writeln(Math.abs(-345)); </script> </body> </html>
<!DOCTYPE html>
<html>
<body>
<script>
document.writeln(Math.abs(-345));
</script>
</body>
</html>