JS: Math. max, min

By Xah Lee. Date: .

max

Math.max(args)

Return the largest of the arguments.

console.log(Math.max(24, 18, 5));
// 24
const xar = [24, 18, 5];
console.log(Math.max(...xar));
// 24

min

Math.min(args)

Return the smallest of the arguments. e.g. Math.min(...xArray)

JavaScript. math functions.