Arguments vs Parameters: What you need to know

Arguments vs Parameters: What you need to know

tdlr; Functions have parameters, function calls have arguments.

After positive reception from my article on brackets/braces/parentheses I thought I would share another set of ambiguous terms with you; arguments and parameters!

While knowing the proper use of these terms isn’t particularly valuable to reduce miscommunication it is likely to improve your mental model of functional programming.

Parameters are defined as part of a function or method signature (they are technically different things). x and y in the following would be considered “parameters”:

function foo(x: number, y: number) {
   return x+y

Arguments are the variables or values that are passed into a function call. a and bin the following would be considered arguments:

const a = 2;
const b = 3;

const sum = foo(a,b);

*Note: a and b are only arguments in the last line when they within the parentheses.

The key distinction is that a parameter can be any value but an argument is a specific value. Pointing this out to a colleague will probably just get you some eye rolls but knowing how to write functions with appropriate parameters and calling them with the matching arguments is integral to the paradigm of functional programming and appropriate terminology is a great place to start.