Question:

What does the following code print to the console?

function c(f) {
  return f();
}
function blub() {
  return "monsters";
}
c(blub);

Answer:

"monsters"

The c() function takes a callback function as a parameter. blub is passed to c() as an argument and is invoked within the body of c().

Functions are "first class" in JavaScript because they can be passed as parameters and stored in data structures.


Keywords:

© 2017 QuizBucket.org