diff --git a/lib/internal/cluster/master.js b/lib/internal/cluster/master.js index a0e194c63ef3c3..3869ebbd8a40a2 100644 --- a/lib/internal/cluster/master.js +++ b/lib/internal/cluster/master.js @@ -80,10 +80,7 @@ cluster.setupMaster = function(options) { if (message.cmd !== 'NODE_DEBUG_ENABLED') return; - var key; - for (key in cluster.workers) { - const worker = cluster.workers[key]; - + for (const worker of Object.values(cluster.workers)) { if (worker.state === 'online' || worker.state === 'listening') { process._debugProcess(worker.process.pid); } else { @@ -227,11 +224,10 @@ cluster.disconnect = function(cb) { if (workers.length === 0) { process.nextTick(() => intercom.emit('disconnect')); } else { - for (var key in workers) { - key = workers[key]; - - if (cluster.workers[key].isConnected()) - cluster.workers[key].disconnect(); + for (const worker of Object.values(cluster.workers)) { + if (worker.isConnected()) { + worker.disconnect(); + } } }