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 trialMax van den Berge
6,506 PointsWhy is this called a parameter and not an argument?
in lesson 1 (see below) i took a reference of the video that tought me the difference between a parameter and an argument. in lesson 2 there is also a function used. The word they use to describe inside the () is called a /** argument / function executeCallback ( callback) / argument / , but i thougt it would be named a / parameter **/
and that this part of the code inside the () , executeCallback(sayHello); would be the /** argument **/
thanks for taking the time to read this :) greetings, Max
/////////////////////////////////
(lesson 1) Function Parameters and Arguments 4:48 with Guil Hernandez https://teamtreehouse.com/library/function-parameters-and-arguments
JavaScript functions can also accept information called arguments0:55 which you pass to the function.0:59 To have a function accept an argument,1:01 you add what's called a parameter inside the parentheses when creating a function.1:04 Inside your function, you can use the parameter just like any variable.1:17 So now, this function is expecting information.1:22
Each time you call the function, you need to pass it the information,1:25 also called passing an argument to the function.
To summarize, a function parameter represents a value that1:38 you supply to the function via an argument so1:42 that the function could do something with that value.
function goToCoffeeShop ( drink)/** parameter /{
alert(Your ${drink} is on the way!
);
}
goToCoffeeShop (Espresso
); / argument **/
goToCoffeeShop (Coffee
);
////////////////////////////////////
(lesson 2) Creating a Simple Callback Function3:42 with Andrew Chalkley
const sayHello= function() { console.log('Hello'); }
function executeCallback ( callback) /** argument **/ { callback(); }
executeCallback(sayHello);
here's a single function called sayHello. It logs out Hello to the console.
This will be the callback function we want to execute.
Let's create a function called, executeCallback. With one argument, callback we'll call the callback function by using parentheses. This is in essence what any function requiring a callback would do. It would execute / invoke/call the callback with (because of the) parentheses.
1 Answer
Steven Parker
231,269 PointsWhen you use a function, the value(s) you pass to it are called arguments. But when you define a function, the names you give to the temporary variables that will hold the argument values are the parameters. For examples:
function test(bla) { // "bla" is a parameter
return "you said " + bla;
}
let thing = "cheese";
let quote = test(thing); // "thing" is an argument
Max van den Berge
6,506 PointsMax van den Berge
6,506 PointsThx for the replay, from lesson 1 (see above) i learned indeed the difference between a parameter and an argument, as you wrote in your awnser.
in lesson 2 , i copied the text and (callback) is called an argument, and my question is indeed if this should not be called a parameter ?
const sayHello= function() { console.log('Hello'); }
function executeCallback ( callback) /** argument **/ { callback(); }
executeCallback(sayHello);
here's a single function called sayHello. It logs out Hello to the console.
This will be the callback function we want to execute.
Let's create a function called, executeCallback. With one argument, callback we'll call the callback function by using parentheses. This is in essence what any function requiring a callback would do. It would execute / invoke/call the callback with (because of the) parentheses.
Steven Parker
231,269 PointsSteven Parker
231,269 PointsCan you provide a link to the page itself?
Steven Parker
231,269 PointsSteven Parker
231,269 PointsSo it's a function "with one argument" (or: a function that takes one argument). But the name "callback" is a parameter. I can see how having both of these in the same sentence might be a bit confusing.
If you really feel this is a bug in the video, you can report it to the Support staff. If they agree, and you are the first to report it, you'll get the "special Exterminator badge".