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 trialMichaela Pecot
5,364 Pointshow is a parameter different from an argument?
when I look up the definition of parameter in javascript, it just seems to be the variable passed into a function, which is what I thought an argument was. I am wondering what the difference is between the two.
1 Answer
Steven Parker
231,275 PointsThe difference is a bit subtle. A parameter is the name you use in the function definition as a placeholder for the values that will be passed later when the function is called. It's essentially a variable but you don't have to declare it.
On the other hand, an argument is a value that you pass when you make the call. For example:
function sum(a, b) { // <-- "a" and "b" are both parameters
return a + b;
}
total = sum(price, tax); // <-- "price" and "tax" are both arguments