/

HTML / CSS / JavaScript Tutorial

JavaScript Math method: max()

[this page | pdf | back links]

The max() method (of the Math object) returns the maximum of a set of real numbers.

 

It has the following syntax with the following parameters:

 

Math.max(x1, x2, x3, …)

 

Parameter

Required / Optional

Description

x1, x2, x3, …

Required

Input values

 

You can find the maximum of an array using a format such as:

 

Math.max.apply(null, xarray)

 

since e.g. Math.max.apply(null, [1, 2, 3]) is equivalent to Math.max(1, 2, 3)

 


NAVIGATION LINKS
Contents | Prev | Next | JavaScript Numbers and Math


Desktop view | Switch to Mobile