Skip to main content

Parameter

In Turkish
Parametre
Pronunciation
puh-RAM-uh-ter
Updated 2 min read

Share this page

Send the link, quote the definition with a link back, or show it as a card on your own site.

https://softwaredictionary.org/terms/parameter

In short

A parameter is a named input in a function's definition, and an argument is the actual value passed in that place when the function is called.

What is a parameter in programming?

In function area(width, height), width and height are parameters: placeholders the function uses in its body. When the code calls area(3, 4), the values 3 and 4 are arguments, and inside that call width is 3 and height is 4. The terms are often used interchangeably in conversation, but the distinction helps when reading documentation and error messages.

Languages offer several ways to pass arguments. Positional arguments are matched by order; named or keyword arguments are matched by name, as in Python's area(width=3, height=4); default parameters supply a value when the caller leaves one out; and rest or variadic parameters, such as ...items in JavaScript or *args in Python, collect any number of extra arguments.

How an argument reaches the function also matters. Primitive values such as numbers are copied, so changing the parameter doesn't affect the caller. Objects and lists are usually passed as references, so a function that modifies the object it received changes the caller's object too, even though reassigning the parameter itself does not.

A common misconception is that a function with many parameters is flexible. Long parameter lists are hard to call correctly, because it is easy to swap two values of the same type. Grouping related values into one options object, or using named arguments, makes calls clearer and safer.

Key takeaways

  • Parameters are the named inputs in a function definition.
  • Arguments are the values passed in when the function is called.
  • Arguments can be positional, named, defaulted or variadic.
  • Objects are usually passed by reference, so changes can reach the caller.
  • Long parameter lists are error-prone; an options object helps.

Example

Parameters, arguments, defaults and rest parameters (JavaScript)javascript
// width and height are parameters; unit has a default value
function area(width, height, unit = "m²") {
  return `${width * height} ${unit}`;
}

area(3, 4);          // 3 and 4 are arguments → "12 m²"
area(3, 4, "cm²");   // overrides the default

// A rest parameter collects any number of arguments
function sum(...numbers) {
  return numbers.reduce((total, n) => total + n, 0);
}
sum(1, 2, 3, 4);     // 10

// An options object instead of a long parameter list
function createUser({ name, email, admin = false }) { /* ... */ }
createUser({ name: "Ada", email: "ada@example.com" });

Readers ask

What is the difference between a parameter and an argument?

A parameter is the variable named in the function definition. An argument is the value supplied for it in a particular call. In greet(name) called as greet("Ada"), name is the parameter and "Ada" is the argument.

What is a default parameter?

A parameter with a value that is used when the caller doesn't pass one, such as function greet(name = "friend"). It keeps calls short for the common case.

Are arguments passed by value or by reference?

It depends on the language and the type. Most languages copy primitive values and pass objects as a reference to the same object, so mutating the object inside the function is visible outside, while reassigning the parameter is not.

See also

Spotted a mistake or something missing on this page?Suggest an edit

Read a random page
Open today's review
Switch to the dark theme
Read this page in Türkçe

More

Settings