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 Functions Pass Information Into Functions Parameters and Arguments Review

how 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
Steven Parker
217,602 Points

The 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