Question 12
Back to Exercise
What does the following JavaScript code print (console output, as in Node.js)?
"use strict";
function show() {
return this;
}
console.log(show());
- A The global object
- B {}
- C undefined Correct
- D null
Correct Answer: Option C
In strict mode a function called on its own gets this = undefined. Without "use strict" it would be the global object.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!