From 91952b6b5e78433125c20f6c54d34b491262105a Mon Sep 17 00:00:00 2001 From: Minwoo Jung Date: Sun, 15 Nov 2015 13:56:05 +0900 Subject: [PATCH] util: use Object.create(null) for dictionary object Fixes https://github.com/nodejs/node/issues/3788 `arrayToHash()` needs to use `Object.create(null)` for its dictionary object. --- lib/util.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/util.js b/lib/util.js index 97c5c10fd87375..b034b29b55f74a 100644 --- a/lib/util.js +++ b/lib/util.js @@ -159,9 +159,9 @@ function stylizeNoColor(str, styleType) { function arrayToHash(array) { - var hash = {}; + var hash = Object.create(null); - array.forEach(function(val, idx) { + array.forEach(function(val) { hash[val] = true; });