catalins.tech with Gatsby

What Is The Difference Between Parameter And Argument? πŸ€”

2020 Jun 17th

Many developers, myself included, use the words “parameter” and “argument” interchangeably. However, their meanings are not the same. In this article, I explain the subtle difference between these two terms. 

Therefore, let us clarify what each of these terms means.

PARAMETERS

The parameters refer to the variables that are in the method/function definition. These variables, which we call parameters, receive a value when we call the function or the method. We can think of them as placeholders. In other words, they tell us what values we need to pass to the function/method.

However, an example helps us understand this term better. 

function sayHello(name) {
    console.log(`Hello ${name}!`);
}

In the above function, the “name” variable is the parameter. The “name” parameter gets assigned a value when we call the function sayHello

ARGUMENTS

The term “arguments” refers to the actual value we pass to the function when we call it. When we call the function sayHello with the value “Catalin Pit”, the value is the argument.

function sayHello(name) {
    console.log(`Hello ${name}!`);
}


sayHello("Catalin Pit");

In the above example, “Catalin Pit” is the argument. In other words, the parameters are the placeholders for where the arguments (values) go.

CONCLUSION

I hope you understand now what is the difference between these two terms.

To sum up, the parameters are in the method/function definition, and they are placeholders for the actual values we pass when calling the method/function. On the other hand, arguments are the actual values that we pass when we call the function/method.

By the way, if you like my articles, consider subscribing to my newsletter!

OTHER ARTICLES OF MINE