Question:

What does the following code print to the console?

result = function surfer() {
  return this === window;
}();
console.log(result);

Answer:

true

There are four different ways to invoke functions in JavaScript and this example demonstrates invocation as a function. The keyword "this" equals window for functions that are invoked as functions.


Keywords:

© 2017 QuizBucket.org