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 Foundations Functions Arguments

Bob Goldsmith
Bob Goldsmith
5,444 Points

What is the difference between an Argument and a Parameter?

Are they just interchangeable synonyms or is there a specific difference?

5 Answers

Andrew Kiernan
Andrew Kiernan
26,892 Points

Hey Bob:

A parameter is a property that you explicitly set/pass into a function. In the code below the name variable is a parameter of the function.

function sayName(name) {console.log("Hi" + name)}; 

In Javascript, the Arguments parameter is one that is passed into every function, and can be accessed kind of like an array (it is technically not an array iirc, a bit confusing but it is what it is). So with the above function if you called it like this:

sayName("Andrew", "Kiernan")

The value "Kiernan" would be accessible as arguments[1] (your own parameters take the first however many spaces of the arguments "array").

I hope that helps, and I assume this is what the video covered (haven't watched it in a while). It could be they were used interchangeably, but in practice if someone uses the Arguments variable, this is what they are referring to.

Let me know if you have any questions!

-Andrew

Bob Goldsmith
Bob Goldsmith
5,444 Points

Thanks Andrew. This does indeed help. I'm making notes as I go and I just want to get my terminology correct.

parameter is what you specify when you create a function, and argument is what you pass into that function when you are calling it

Janek Rezner
Janek Rezner
12,973 Points

some people call it parameter others call it arguments.

Janek Rezner
Janek Rezner
12,973 Points

actually i'm wrong! People use them interchangeably but the main deference is that parameters are used inside functions and the arguments are the values passed when a function is called....

Bob Goldsmith
Bob Goldsmith
5,444 Points

No worries, thanks for replying :)