Bird
0
0

Which of the following is the correct way to check if the current process is the master in a cluster setup?

easy📝 Syntax Q12 of 15
Node.js - Cluster Module
Which of the following is the correct way to check if the current process is the master in a cluster setup?
Aif (cluster.isMaster) { ... }
Bif (cluster.isPrimary) { ... }
Cif (cluster.isWorker) { ... }
Dif (cluster.isMain) { ... }
Step-by-Step Solution
Solution:
  1. Step 1: Recall the updated property name

    In recent Node.js versions, cluster.isPrimary replaces cluster.isMaster.
  2. Step 2: Identify the correct syntax

    Using cluster.isPrimary correctly checks if the process is the primary (master) process.
  3. Final Answer:

    if (cluster.isPrimary) { ... } -> Option B
  4. Quick Check:

    Primary process check = cluster.isPrimary [OK]
Quick Trick: Use cluster.isPrimary, not isMaster [OK]
Common Mistakes:
  • Using deprecated cluster.isMaster instead of cluster.isPrimary
  • Confusing isWorker with isPrimary
  • Using non-existent properties like isMain

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Node.js Quizzes