[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Math/max [Back]  [Original]

Math.max() - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

Math.max()

Baseline Widely available

This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 7.

Math.max() , -Infinity .

In this article

console.log(Math.max(1, 3, 2));
// Expected output: 3

console.log(Math.max(-1, -3, -2));
// Expected output: -1

const array1 = [1, 3, 2];

console.log(Math.max(...array1));
// Expected output: 3

js
Math.max()
Math.max(value1)
Math.max(value1, value2)
Math.max(value1, value2, /* , */ valueN)

value1, , valueN

0 .

. NaN NaN . -Infinity .

max() Math Math Math.max() . (Math ).

Math.max.length 2 , 2 .

Math.max()

js
Math.max(10, 20); // 20
Math.max(-10, -20); // -10
Math.max(-10, 20); // 20

Array.prototype.reduce() .

js
const arr = [1, 2, 3];
const max = arr.reduce((a, b) => Math.max(a, b), -Infinity);

Function.prototype.apply() . getMaxOfArray([1, 2, 3]) Math.max(1, 2, 3) , getMaxOfArray() . .

js
function getMaxOfArray(numArray) {
  return Math.max.apply(null, numArray);
}

apply .

js
const arr = [1, 2, 3];
const max = Math.max(...arr);

(...) apply . apply . reduce .

Specification
ECMAScript 2027 LanguageSpecification
# sec-math.max


Web Proxy Viewer  |  New URL  |  Original Page