-1

Am I right in my understanding of this code. We call the function with an anonymous function. It firstly console logs the function ( as in the function structure, it does not run the function. It then runs the function when it comes across a();

Is this correct?

var runIt = function(a) {
    console.log(a);
    a();
};

runIt(function({
    var b = " Now";
    console.log("Running" + b); 
});
Cerbrus
  • 70,800
  • 18
  • 132
  • 147

1 Answers1

1

We call the function with an anonymous function. It firstly console logs the function (as in: the function structure), it does not run the function. It then runs the function when it comes across a().

Is this correct?

Yes.

JavaScript function expression and function declaration, am I right in my understanding?

No. This code has nothing to do with function expressions vs function declarations.

Bergi
  • 630,263
  • 148
  • 957
  • 1,375