Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialBob Goldsmith
5,444 PointsWhat is the difference between an Argument and a Parameter?
Are they just interchangeable synonyms or is there a specific difference?
5 Answers
Andrew Kiernan
26,892 PointsHey 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
linas mickevicius
Courses Plus Student 1,261 Pointsparameter is what you specify when you create a function, and argument is what you pass into that function when you are calling it
Vlad Pekh
16,771 Pointshttp://www.w3schools.com/js/js_function_parameters.asp - good explanation with examples!
Janek Rezner
12,973 Pointssome people call it parameter others call it arguments.
Janek Rezner
12,973 Pointsactually 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
5,444 PointsNo worries, thanks for replying :)
Bob Goldsmith
5,444 PointsBob Goldsmith
5,444 PointsThanks Andrew. This does indeed help. I'm making notes as I go and I just want to get my terminology correct.