diff --git a/lib/util.js b/lib/util.js index 6453727ad843b0..1ee96c1c84be11 100644 --- a/lib/util.js +++ b/lib/util.js @@ -361,6 +361,10 @@ function formatValue(ctx, value, recurseTimes) { // for boxed Strings, we have to remove the 0-n indexed entries, // since they just noisy up the output and are redundant keys = keys.filter(function(key) { + if (typeof key === 'symbol') { + return true; + } + return !(key >= 0 && key < raw.length); }); } diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index 53f7e3014b389e..ded4e4a47f71d5 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -50,6 +50,9 @@ assert.strictEqual(util.inspect(Object.create({}, {visible: {value: 1, enumerable: true}, hidden: {value: 2}})), '{ visible: 1 }' ); +assert.strictEqual(util.inspect(Object.assign(new String('hello'), + { [Symbol('foo')]: 123 }), { showHidden: true }), + '{ [String: \'hello\'] [length]: 5, [Symbol(foo)]: 123 }'); { const regexp = /regexp/;