diff --git a/lib/console.js b/lib/console.js index 39bcf701bf83eb..a0158ec6643782 100644 --- a/lib/console.js +++ b/lib/console.js @@ -363,9 +363,7 @@ Console.prototype.table = function(tabularData, properties) { tabularData = previewSetIterator(tabularData); const setlike = setIter || isSet(tabularData); - if (setlike || - (properties === undefined && - (isArray(tabularData) || isTypedArray(tabularData)))) { + if (setlike) { const values = []; let length = 0; for (const v of tabularData) { diff --git a/test/parallel/test-console-table.js b/test/parallel/test-console-table.js index 39e9099dd717d4..64e2533f175e1d 100644 --- a/test/parallel/test-console-table.js +++ b/test/parallel/test-console-table.js @@ -41,13 +41,13 @@ test([1, 2, 3], ` `); test([Symbol(), 5, [10]], ` -┌─────────┬──────────┐ -│ (index) │ Values │ -├─────────┼──────────┤ -│ 0 │ Symbol() │ -│ 1 │ 5 │ -│ 2 │ [ 10 ] │ -└─────────┴──────────┘ +┌─────────┬────┬──────────┐ +│ (index) │ 0 │ Values │ +├─────────┼────┼──────────┤ +│ 0 │ │ Symbol() │ +│ 1 │ │ 5 │ +│ 2 │ 10 │ │ +└─────────┴────┴──────────┘ `); test([undefined, 5], ` @@ -182,10 +182,10 @@ test({ a: undefined }, ['x'], ` `); test([], ` -┌─────────┬────────┐ -│ (index) │ Values │ -├─────────┼────────┤ -└─────────┴────────┘ +┌─────────┐ +│ (index) │ +├─────────┤ +└─────────┘ `); test(new Map(), ` @@ -194,3 +194,12 @@ test(new Map(), ` ├───────────────────┼─────┼────────┤ └───────────────────┴─────┴────────┘ `); + +test([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }], ` +┌─────────┬─────┬─────┐ +│ (index) │ a │ b │ +├─────────┼─────┼─────┤ +│ 0 │ 1 │ 'Y' │ +│ 1 │ 'Z' │ 2 │ +└─────────┴─────┴─────┘ +`);