Bird
0
0

Assuming const { fork } = require('child_process'); which of the following is the correct syntax to fork a child process running child.js?

easy📝 Syntax Q3 of 15
Node.js - Child Processes
Assuming const { fork } = require('child_process'); which of the following is the correct syntax to fork a child process running child.js?
Aconst child = child_process.fork('child.js');
Bconst child = fork.child('child.js');
Cconst child = fork('child.js');
Dconst child = fork().run('child.js');
Step-by-Step Solution
Solution:
  1. Step 1: Recall correct fork usage

    After importing fork from child_process, the syntax is fork('child.js').

  2. Step 2: Check other options for syntax errors

    A uses child_process which is undefined, B uses incorrect method chaining fork.child('child.js'), D uses invalid method chaining.

  3. Final Answer:

    const child = fork('child.js'); -> Option C
  4. Quick Check:

    fork syntax = fork('file') [OK]

Quick Trick: Use fork('filename') after importing fork [OK]
Common Mistakes:
  • Using incorrect method chaining
  • Not importing fork correctly
  • Calling fork without arguments

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Node.js Quizzes