Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumNodeJSWorker threads basicsSingle-choice MCQ

In a Node.js process, what does this code log and why?

const { Worker, isMainThread, threadId } = require('worker_threads'); if (isMainThread) { new Worker(__filename); console.log('main', threadId); } else { console.log('worker', threadId); }