From 31dacfe631e389505bb3ce17dff05e938eaee1ff Mon Sep 17 00:00:00 2001 From: gengjiawen Date: Fri, 1 Mar 2019 00:36:38 +0800 Subject: [PATCH] lib: improve for-loop in events.js --- lib/events.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/events.js b/lib/events.js index 2d7ae8945ff0b2..eff75cca18431d 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); }