These two words are used interchangeably. Please don’t. They mean different things. Here is my concise explanation.
Argument
A value passed into a function/method during invocation.
my_func(arg1, arg2)
Additional names for “argument” are “actual argument” and “actual parameter”.
Parameter
A name of a variable in the function/method definition. During invocation, the variable is used in the function/method body to refer to the value of the passed argument.
F my_func(param1, param2) {
...
# Using param1 and param2 for a computation
...
}
Additional name for “parameter” is “formal argument”.
Tip – Parametrize
If you struggle to remember which one is which, this might help: when you “parameterize” a piece of code, you add parameters to the code. Then you have the code with the parameter used in it, with the first occurrence in the function/method definition.
# Initial version
echo("Hello, Joe")
# Parametrized version. "name" is a parameter.
F hello(name) {
echo("Hello, ${name}")
}
See Also
- https://en.wikipedia.org/wiki/Parameter_(computer_programming)
- https://developer.mozilla.org/en-US/docs/Glossary/Argument
- https://developer.mozilla.org/en-US/docs/Glossary/Parameter
- https://stackoverflow.com/questions/156767/whats-the-difference-between-an-argument-and-a-parameter
Hope this helps! Have a nice day!
Updates after Reddit discussion:
- I never asked the difference as an interview question. If I would:
- Getting this wrong – tiny negative point
- Not understanding why using correct terminology matters – big negative point
- Understanding the difference and using these words interchangeably (knowingly incorrectly) – huge negative point
- Providing fake facts to support your opinion that these words are interchangeable – huge negative point
- Explaining why using correct terminology matters is out of scope of this post