Math.max (arg1, arg2, ..., argN) - calculates the maximum number of the passed arguments.
Math.min (arg1, arg2, ..., argN) - returns the minimum value of the passed arguments.
In this article, we will learn how to do the same with our own functions and how to pass parameters to such functions as an array.
You can call a function⚙️ with any number of arguments, regardless of how it was defined.
For example 👇:
SyntaxError: Unexpected token (1:8) 1 : return () ^
Extra arguments will not cause an error, but of course only the first three will be counted.
Starting with the ES6 standard, a concept has appeared like
... rest - residual parameters.
Free parameters can be indicated with three dots
.... It literally means: "collect the remaining parameters and put them in an array."
- MDN web doc. Spread syntax article
- Residual Parameters and the Spread Operator article
- The article "The spread and rest operator"
Thanks goes to these wonderful people (emoji key):
🐛 🎨 🖋
🖋 🐛 🎨