Question Details

No question body available.

Tags

javascript

Answers (7)

January 8, 2026 Score: 3 Rep: 4,413 Quality: Low Completeness: 40%

If you don't like to use the spread operator, there's always .apply: Math.max.apply(null, [10, 25, 7, 40]). If that is better is a matter of taste (IMHO: No).

Sadly, the world does not always live up to ones expectations and sometimes things are just the way they are.

January 8, 2026 Score: 2 Rep: 80,803 Quality: Medium Completeness: 80%

Math.max has been widely available since July 2015. The spread operator has been widely available since October 2015. So the operator did not exist when the function was implemented. However, you can do something like this in your project:

Math.Max = function(array) {
    return Math.max(...array);
}

console.log(Math.Max([4,2,6,2]));

So you will be able to call Math.Max which under the hood will call Math.max and handle your array.

January 8, 2026 Score: 1 Rep: 1 Quality: Low Completeness: 60%

Math.max wasn’t designed “wrong”—it was designed early.

  • It predates modern JS patterns

  • It follows math notation

  • Spread exists to bridge old APIs with modern code

  • Overloading with arrays would harm predictability and performance

January 8, 2026 Score: 1 Rep: 524,874 Quality: Low Completeness: 40%

Spread exists to bridge old APIs with modern code

The spread operator is just modern syntactic sugar; you could always use .apply to "bridge old APIs".

January 8, 2026 Score: 1 Rep: 524,874 Quality: Low Completeness: 40%

I would not recommend that. Just use .... It's hardly any more inconvenient, but it's widely understood and available.

Modifying builtins to add new methods always has the potential for problems. Since this will be a polyfill, you'd need to make sure you're not polyfilling this hack in two different places, possibly in different ways. It also looks like a typo to the uninitiated and is unexpected.

January 8, 2026 Score: 1 Rep: 7,524 Quality: Low Completeness: 90%

The spread operator makes readability unnecessarily difficult.

I guess that's a matter of opinion because I love it. It avoids having to use the apply method like in the old days. It's also very readable as it succulently shows that the parameter is an expanded iterable.

Regardless, neither one of these seem unnecessarily difficult:

  • JavaScript Math.max(...array)

  • Python max(array)

Python is one of the few languages that will accept an iterable as a max parameter.

January 8, 2026 Score: 1 Rep: 4,413 Quality: Low Completeness: 70%

That "answer" not only contains wrong information (the Math object has at least been in the standard since 1997 and is "widely available" since long before 2015), it also encourages bad practice (ever heard of "do not modify objects you don't own"? The suggested practice is the reason why Array.prototype.flat is not named .flatten as it was initially planned - see for more information and why modifying built-ins is a big no-no)