From 8b0164aa264fb1b689e6e1a088084c797f8a39ad Mon Sep 17 00:00:00 2001 From: gengjiawen Date: Fri, 1 Mar 2019 00:36:38 +0800 Subject: [PATCH] events: improve for-loop PR-URL: https://github.com/nodejs/node/pull/26354 Reviewed-By: Ruben Bridgewater Reviewed-By: Beth Griggs --- lib/events.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/events.js b/lib/events.js index ec5e0870aa50a0..5e899edbe909dd 100644 --- a/lib/events.js +++ b/lib/events.js @@ -390,10 +390,7 @@ EventEmitter.prototype.removeAllListeners = // Emit removeListener for all listeners on all events if (arguments.length === 0) { - var keys = Object.keys(events); - var key; - for (i = 0; i < keys.length; ++i) { - key = keys[i]; + for (const key of Object.keys(events)) { if (key === 'removeListener') continue; this.removeAllListeners(key); }