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 trialBenjamin Lowry
7,941 PointsDifference between argument and parameters
Am I correct in saying that parameters are what you define in the parenthesis when you make a new function? And an argument is what you put into the function parenthesis when you call that function later? Not sure if this right and couldn't get to the bottom of it from the video. Hope there is a simple explanation. Thanks!
3 Answers
SP Prabhakar
11,429 PointsDear Benjamin, parameter is a kind of placeholder. It keeps values in side it. And the value is nothing but its arguments. Such as if you declare a function, sayHello(x,y), here x and y are two parameters and when you call this function with some value like sayHello(4,5) then 4 and 5 are arguments.
Shadab Khan
5,470 PointsHi Benjamin,
You are right.
Let's see an example:
//in function Sum, a & b are the function parameters
function Sum(a, b) {
return a + b;
}
In the below expression, when you're calling the above function, values 2 & 3 that you pass are the Sum function's arguments.
var x = Sum(2, 3);
Hope that makes it clear for you. All the best :)
Erika Suzuki
20,299 PointsI've been programming for years, and i didn't know the how to call them apart. I used 'parameters' and 'arguments' interchangeably. Thanks, now it's clear.
robertvandeweghe
8,120 PointsThe parameter is a placeholder yes! When the function is called, the parameter BECOMES an argument.