Question:

What does the following example print to the console?

console.log((function (x, y) { return x + y })(3, 4));

Answer:

7

The anonymous function in this example is defined and invoked on the same line. JavaScript functions are frequently invoked immediately after they are defined, so be prepared to see this technique used frequently.


Keywords:

© 2017 QuizBucket.org