About "argument function"

I am reading the context in the following lesson:

In the paragraph: "

When we invoke a higher-order function, and pass another function in as an argument, we don’t invoke the argument function. Invoking it would evaluate to passing in the return value of that function call. With callback functions, we pass in the function itself by typing the function name without the parentheses"

I don’t understand what argument function mean here.
Basically, I don’t understand the meaning of this paragraph since it is hard to understand.

I think it means like this:

function function1 (/*argument here*/) {
  // do stuff here
function function2 (function1) {
  // do stuff here

In this case, function1 is an argument in function 2. What it’s saying is that it doesn’t invoke, or run, function 1 when you do that.


There is a difference between the function itself and the valued returned by the function after it has been called/invoked.

function myFunction() {
  return 1 + 2


The above function simply adds one and two together. But the console.log statements will produce different output.

The first console.log statement will log the actual function. The output will be [Function: myFunction].

The second console.log statement will output the result of calling/invoking the function, which is 3.

If you type myFunction, you are referring to the function itself, the actual code that makes up the function.

If you type myFunction(), you are referring to the result of the function being called/invoked.

Obviously, if you’re passing a function as an argument to another function, the output of the higher-order function will be different based on whether you have passed in [Function: myFunction] or 3 as an argument.

Hope this helps!