diff --git a/lib/util.js b/lib/util.js index 07fbe15f38cb70..590a3b49034345 100644 --- a/lib/util.js +++ b/lib/util.js @@ -594,11 +594,9 @@ function formatValue(ctx, value, recurseTimes, ln) { return ctx.stylize('[Circular]', 'special'); if (recurseTimes != null) { - if (recurseTimes < 0) { - if (Array.isArray(value)) - return ctx.stylize('[Array]', 'special'); - return ctx.stylize('[Object]', 'special'); - } + if (recurseTimes < 0) + return ctx.stylize(`[${constructor ? constructor.name : 'Object'}]`, + 'special'); recurseTimes -= 1; } diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index 70f7c4d43139ea..02e35ec9e85562 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -994,6 +994,10 @@ if (typeof Symbol !== 'undefined') { 'MapSubclass { \'foo\' => 42 }'); assert.strictEqual(util.inspect(new PromiseSubclass(() => {})), 'PromiseSubclass { }'); + assert.strictEqual( + util.inspect({ a: { b: new ArraySubclass([1, [2], 3]) } }, { depth: 1 }), + '{ a: { b: [ArraySubclass] } }' + ); } // Empty and circular before depth