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 trial
Joseph Graham
Courses Plus Student 340 PointsI'm pretty much confuse "Parameter" and "Argument" Any TreeHouse Author help me???
I got "Parameter" and "Argument" kind of mixed up and did not really pay attention to when to use one and when to use the other. Please Sir Can you tell me by any workShop. this is not only my problem i think every beginner got same problem i think best solution workShop
2 Answers
Matt F.
9,518 PointsHi Joseph,
Parameter and Argument are often used as synonyms in real world situations.
When you are getting into nuanced conversations however, the difference between the two is that Parameters are what we use when declaring a function, while arguments are the values that we pass into that function upon its execution.
For example:
function exampleFunc(parameter) {
//parameter is the parameter we refer to when declaring a function
console.log(parameter)
}
//when a value is passed to the exampleFunc, its value is considered the 'argument' which is assigned to the parameter parameter
exampleFunc("argument");
Essentially what happens when we call exampleFunc with "argument" as its argument is that "argument" is assigned to the parameter parameter of exampleFunc.
jack AM
2,618 PointsYea totally, I got them mixed up too as well lol check it, "parameters" are the variables being used in the function declaration.
function sum( numOne, numTwo ) {...}
So it can be said that the function Sum, has two parameters, numOne and numTwo.
However, when the function is ACTUALLY being called, what is being tossed into the function are the "arguments."
sum(2, 5);
Here, 2 and 5 are the arguments. Also http://stackoverflow.com/questions/1788923/parameter-vs-argument explains it pretty good too.