Bird
0
0

Which of the following is the correct syntax to schedule a function to run after 100 milliseconds in Node.js?

easy📝 Syntax Q3 of 15
Node.js - Timers and Scheduling
Which of the following is the correct syntax to schedule a function to run after 100 milliseconds in Node.js?
AsetInterval(() => { /* code */ }, 100);
BsetTimeout(() => { /* code */ }, 100);
CsetTimeout(100, () => { /* code */ });
DsetImmediate(() => { /* code */ }, 100);
Step-by-Step Solution
Solution:
  1. Step 1: Recall setTimeout syntax

    The correct syntax is setTimeout(callback, delay), where delay is in milliseconds.
  2. Step 2: Identify correct option

    setTimeout(() => { /* code */ }, 100); matches the correct syntax with callback first, then delay.
  3. Final Answer:

    setTimeout(() => { /* code */ }, 100); -> Option B
  4. Quick Check:

    setTimeout(callback, delay) syntax [OK]
Quick Trick: setTimeout(callback, delay) always callback first [OK]
Common Mistakes:
  • Swapping arguments order
  • Using setInterval instead of setTimeout
  • Passing delay to setImmediate

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Node.js Quizzes