Bird
0
0

Which of the following is the correct way to create a new Worker thread in Node.js?

easy📝 Syntax Q3 of 15
Node.js - Worker Threads
Which of the following is the correct way to create a new Worker thread in Node.js?
AWorker.create('./worker.js')
Bnew Worker('./worker.js')
CworkerThread('./worker.js')
DcreateWorker('./worker.js')
Step-by-Step Solution
Solution:
  1. Step 1: Recall Worker class usage

    The Worker class is instantiated with the path to the worker script as a string.
  2. Step 2: Verify correct syntax

    The correct syntax is new Worker('./worker.js'). Other options are not valid methods or functions.
  3. Final Answer:

    new Worker('./worker.js') -> Option B
  4. Quick Check:

    Create worker with new Worker(path) [OK]
Quick Trick: Use new Worker('file.js') to start a worker thread [OK]
Common Mistakes:
  • Using non-existent create() method
  • Calling workerThread() which is not a function
  • Using createWorker() which does not exist

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Node.js Quizzes