Skip to content
2 changes: 1 addition & 1 deletion lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ function stylizeNoColor(str, styleType) {


function arrayToHash(array) {
var hash = {};
var hash = Object.create(null);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not a Set instead?


array.forEach(function(val, idx) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if idx is not used, why pass it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YuriSolovyov Hmm, It was there before I made a PR,
I speculate that it could be used

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is not used anywhere in the scope of the function, IMO it is safe to drop it

hash[val] = true;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'd check if val was __proto__ here and discard it if it was, I think. cc @bnoordhuis

Expand Down