The arguments Object

Using Functions

The arguments Object

🙋 Need help? Ask an expert now!

Every function in JavaScript has an implicit parameter arguments. This parameter holds information about the function and all the parameters passed to the function. The parameter arguments doesn't need to be explicitly declared. Although the argument parameter exhibits some array functionality, it is not an array, and using it is not recommended as it could cause unwanted bugs in your program.

Instead of having a parameter to take in the values, the implicit parameter arguments is used. The arguments parameter automatically detects the values inside the set of parenthesis and applies statements to the given input. Since the use of arguments can confuse many programmers as well as cause unwanted errors, it is not a recommended method for using a function. However, if this makes sense to you and you want to use it in the future, feel free to explore this concept and expand your knowledge about it.

Edit Me on GitHub!

Application Question

Consider the following code segment:

let sum = 0;
function addArguments() {
    var i;
    for (i in arguments) {
        sum += i;

What will the following code segment print to the console?