Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Basics (Retired) Creating Reusable Code with Functions Giving Information to Functions

Benjamin Lowry
Benjamin Lowry
7,941 Points

Difference between argument and parameters

Am I correct in saying that parameters are what you define in the parenthesis when you make a new function? And an argument is what you put into the function parenthesis when you call that function later? Not sure if this right and couldn't get to the bottom of it from the video. Hope there is a simple explanation. Thanks!

3 Answers

SP Prabhakar
SP Prabhakar
11,429 Points

Dear Benjamin, parameter is a kind of placeholder. It keeps values in side it. And the value is nothing but its arguments. Such as if you declare a function, sayHello(x,y), here x and y are two parameters and when you call this function with some value like sayHello(4,5) then 4 and 5 are arguments.

Shadab Khan
Shadab Khan
5,470 Points

Hi Benjamin,

You are right.

Let's see an example:

//in function Sum, a & b are the function parameters

function Sum(a, b) {
 return a + b;
}

In the below expression, when you're calling the above function, values 2 & 3 that you pass are the Sum function's arguments.

var x = Sum(2, 3);

Hope that makes it clear for you. All the best :)

Erika Suzuki
Erika Suzuki
20,299 Points

I've been programming for years, and i didn't know the how to call them apart. I used 'parameters' and 'arguments' interchangeably. Thanks, now it's clear.

The parameter is a placeholder yes! When the function is called, the parameter BECOMES an argument.