Bird
0
0

Which of the following is the correct way to check if the current process is a worker in a Node.js cluster?

easy📝 Syntax Q3 of 15
Node.js - Cluster Module
Which of the following is the correct way to check if the current process is a worker in a Node.js cluster?
Acluster.isMaster === true
Bcluster.isWorker === true
Cprocess.isWorker === true
Dcluster.isPrimary === false
Step-by-Step Solution
Solution:
  1. Step 1: Recall cluster properties

    Node.js cluster module provides cluster.isWorker to check if the process is a worker.
  2. Step 2: Eliminate incorrect options

    cluster.isMaster checks for master, process.isWorker does not exist, and cluster.isPrimary is a newer alias but checking false is less direct.
  3. Final Answer:

    cluster.isWorker === true -> Option B
  4. Quick Check:

    Use cluster.isWorker to check worker = B [OK]
Quick Trick: Use cluster.isWorker to identify worker process [OK]
Common Mistakes:
  • Using cluster.isMaster to check worker
  • Using process object incorrectly
  • Confusing isPrimary with isWorker

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Node.js Quizzes