Parameters Vs Arguments

I was wondering if the use of the term parameters in these lessons is technically correct. I’m not that familiar with JavaScript, but in other languages, I’ve heard the term arguments used for data that is passed when functions are called.

You are correct. Technically, parameters are the variables in the function. Arguments are the values you pass to those variables.

function doMath(a, b){
return a+b;
}

doMath(7,8)

In the above “a” and “b” are parameters of the function doMath, 7 and 8 are the arguments passed to those parameters.

We tried to be consistent about this usage, but no promises. Can you point to an instance where you think we got it wrong?

To be honest a lot of people use the terms interchangeably, or at least inconsistently, and it might not really matter. If I’m having a conversation with a developer about a function’s arguments and then I started saying “parameters” no one would be confused about what we were talking about. No one is going to say “Arguments! I thought we were talking about parameters!” :slight_smile:

The corollary is to think about how you talk about variables and their values - a variable is a container that holds a value, but when you talk about code you use the word “variable” to mean both the container and its value at times.

I realize this is a possible language barrier for students, so I think it’s useful to say they basically mean the same thing and which you use depends on how you’re talking about code in that moment. If you really want to disambiguate then just say “what are the values of those parameters?” or even “what are the values of those arguments?”

For example, if I say, “In your function did you check to make sure the parameters were not null?” Of course what I technically mean by that is “Did you check to see if an argument was passed to that parameter?” or “that the arguments aren’t null”. But often this is so formal as to be useless since it’s not really ambiguous what I’m talking about.

Note: this is my $0.02. Students should know that there is a difference, but in common parlance they are used inconsistently.

–Baker

4 Likes