Parameters vs Arguments: The Difference
You'll learn: The precise distinction between parameters (placeholders in function definitions) and arguments (actual values passed when calling).
The Core Distinction
Think of parameters as empty slots on a form, and arguments as the information you write into those slots.
Parameters are the variable names you define when creating a function. They're placeholders that tell you what information the function expects.
Arguments are the actual values you provide when calling that function. They fill in those placeholders with real data.
Seeing It in Code
// 'name' and 'age' are PARAMETERS
function greet(name, age) {
return `Hello ${name}, you are ${age} years old`;
}
// 'Alice' and 30 are ARGUMENTS
greet('Alice', 30);
When you define greet(name, age), name and age are parameters.
When you call greet('Alice', 30), the values 'Alice' and 30 are arguments.
Why the Distinction Matters
Understanding this terminology helps you communicate clearly with other developers and understand documentation. When someone says "this function takes two parameters," they're describing what the function expects. When discussing "passing the wrong arguments," they mean the actual values you provided were incorrect.
The Mental Model
- Parameters = the recipe's ingredient list
- Arguments = the actual ingredients you use
Key Takeaway: Parameters are the named placeholders in a function definition; arguments are the actual values passed when the function is called.