Member-only story
Arguments Objects in JavaScript
Learn about how to use arguments objects inside function in JavaScript
arguments is an object accessible inside functions that contains the values of the arguments passed to that function.
function test(a, b, c) { console.log(arguments[0], arguments[1], arguments[2]);}test(1,2,3); //1, 2, 3
The arguments object is only available inside non-arrow functions . Also the arguments object is not an array , but we can access using index , also it has length property, which contains the number of arguments passed to the function.
function test(a, b, c) { console.log(arguments.length);}test(1); // 1
test(1, 2); // 2
The arguments objects contains all the argument passed during function call, even there are as many parameter in function declaration
function test() {
console.log(arguments.length);
}test(); //0
test(1); //1
test(1,2,3,5); //4
You can update the value of arguments
function test() {
arguments[0] = 100;
console.log(arguments[0]);
}test(); //100
test(1); //100





