The arguments object is an array-like object that contains all of the arguments passed to a function in JavaScript. This can be used to find arguments passed to a function, even if those arguments are not referenced in the function signature.
function argumentsTest(value1) {
console.log(value1);
console.log(arguments.length);
console.log(arguments);
console.log(arguments[0]);
console.log(arguments[1]);
}
argumentsTest('myvalue');
// 'myvalue'
// 1
// ['myvalue']
// 'myvalue'
// undefined
argumentsTest('myvalue', true, 'another value');
// 'myvalue'
// 3
// ['myvalue', true, 'another value']
// 'myvalue'
// trueSee the Arguments docs on MDN for more details about this object.
Add new comment