Bird
0
0

What is wrong with this code?

medium📝 Debug Q7 of 15
Node.js - Timers and Scheduling
What is wrong with this code?
setImmediate(console.log('Test'));
process.nextTick(() => console.log('Tick'));
AsetImmediate cannot be used with console.log
Bprocess.nextTick callback is missing
CsetImmediate is called with the result of console.log, not a function
DNo error, code runs as expected
Step-by-Step Solution
Solution:
  1. Step 1: Check setImmediate argument

    console.log('Test') is called immediately, passing undefined to setImmediate instead of a function.
  2. Step 2: Verify process.nextTick usage

    process.nextTick is correctly passed a function, so no issue there.
  3. Final Answer:

    setImmediate is called with the result of console.log, not a function -> Option C
  4. Quick Check:

    Pass function, not call result = A [OK]
Quick Trick: Pass a function to setImmediate, not the call result [OK]
Common Mistakes:
  • Calling function immediately instead of passing it
  • Assuming no error with immediate call
  • Confusing function reference and invocation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Node.js Quizzes