JavaScriptEasy

Parameter vs argument — what's the difference?

01

The Short Answer

A parameter is the variable name listed in a function's definition — it's a placeholder that describes what the function expects. An argument is the actual value you pass to the function when you call it. Think of parameters as the labeled slots in the function signature, and arguments as the concrete values you plug into those slots. In function greet(name) {}, name is the parameter. In greet('Alice'), 'Alice' is the argument.

02

The Distinction

The terms are often used interchangeably in casual conversation, but they refer to different things in the function lifecycle. Parameters exist at definition time — they're part of the function's contract. Arguments exist at call time — they're the actual data flowing into the function. This distinction matters when discussing function signatures, overloading, arity, and the arguments object.

params-vs-args.tstypescript
// Parameters: declared in the function definition
//             ↓ parameter    ↓ parameter
function add(first: number, second: number): number {
  return first + second;
}

// Arguments: passed when calling the function
//     ↓ argument  ↓ argument
add(5, 3);

// More examples:
function formatName(firstName: string, lastName: string) {
  //                 ↑ parameter        ↑ parameter
  return `${firstName} ${lastName}`;
}

const fullName = formatName('Alice', 'Johnson');
//                           ↑ argument  ↑ argument

// Default parameters — the default is part of the parameter definition
function greet(name: string, greeting: string = 'Hello') {
  //            ↑ parameter   ↑ parameter with default value
  return `${greeting}, ${name}!`;
}

greet('Bob');           // 1 argument — greeting uses default
greet('Bob', 'Hi');    // 2 arguments — greeting overridden
03

Related Concepts

Understanding the parameter/argument distinction helps clarify several related JavaScript concepts: function arity (the number of parameters), the arguments object (which holds the actual arguments passed), rest parameters (which collect extra arguments), and how JavaScript handles mismatched counts (extra arguments are ignored, missing ones become undefined).

related-concepts.tstypescript
// Function arity = number of parameters
function add(a: number, b: number) { return a + b; }
console.log(add.length); // 2 — two parameters defined

// The arguments object holds actual arguments passed (not available in arrow functions)
function logAll() {
  console.log(arguments); // [1, 2, 3, 4, 5] — all arguments, even without parameters
  console.log(arguments.length); // 5
}
logAll(1, 2, 3, 4, 5);

// Rest parameters collect remaining arguments into an array
function sum(first: number, ...rest: number[]) {
  //          ↑ parameter    ↑ rest parameter (collects extra arguments)
  return rest.reduce((total, num) => total + num, first);
}
sum(1, 2, 3, 4); // first=1, rest=[2,3,4] — 4 arguments, 2 parameters

// Mismatched counts:
function greet(name: string, age: number) {
  console.log(name, age);
}
greet('Alice');        // 'Alice', undefined — missing argument = undefined
// greet('Alice', 30, 'extra'); // JS allows extra args (TS would error)

A quick mnemonic: Parameters are Placeholders (both start with P). Arguments are Actual values (both start with A). Parameters define what's expected; arguments deliver what's provided.

04

Why Interviewers Ask This

This is a terminology question that tests precision in technical communication. Interviewers want to see that you can articulate the difference clearly (definition-time vs call-time), know related concepts like arity, rest parameters, and the arguments object, and communicate precisely about code — which matters when discussing APIs, documentation, and code reviews.

Quick Revision Cheat Sheet

Parameter: Variable in the function definition — the placeholder/slot (definition-time)

Argument: Actual value passed to the function when called (call-time)

Arity: Number of parameters a function declares (fn.length)

arguments object: Array-like object containing all arguments passed (not in arrow functions)

Rest parameter: ...rest collects remaining arguments into a real array

Mnemonic: Parameters = Placeholders, Arguments = Actual values