JavaScript functions have a built-in object called the arguments object.
The argument object contains an array of the arguments used when the function was called (invoked).
This way you can simply use a function to find (for instance) the highest value in a list of numbers:
function func1(a, b, c) {
console.log(arguments[0]);
// expected output: 1
console.log(arguments[1]);
// expected output: 2
console.log(arguments[2]);
// expected output: 3
}
func1(1, 2, 3);
You can access them as follows:
arguments[0] // first argument
arguments[1] // second argument
arguments[2] // third argument
Each argument can also be set or reassigned:
arguments[1] = 'new value';
Learn More: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments