diff --git a/lib/console.js b/lib/console.js index 30a9a0e7331062..406f7007e23c03 100644 --- a/lib/console.js +++ b/lib/console.js @@ -349,7 +349,7 @@ Console.prototype.table = function(tabularData, properties) { if (properties !== undefined && !ArrayIsArray(properties)) throw new ERR_INVALID_ARG_TYPE('properties', 'Array', properties); - if (tabularData == null || typeof tabularData !== 'object') + if (tabularData === null || typeof tabularData !== 'object') return this.log(tabularData); if (cliTable === undefined) cliTable = require('internal/cli_table'); diff --git a/test/parallel/test-console-table.js b/test/parallel/test-console-table.js index 844d2e01e4180b..e5b56ced8435ea 100644 --- a/test/parallel/test-console-table.js +++ b/test/parallel/test-console-table.js @@ -54,6 +54,15 @@ test([Symbol(), 5, [10]], ` └─────────┴────┴──────────┘ `); +test([null, 5], ` +┌─────────┬────────┐ +│ (index) │ Values │ +├─────────┼────────┤ +│ 0 │ null │ +│ 1 │ 5 │ +└─────────┴────────┘ +`); + test([undefined, 5], ` ┌─────────┬───────────┐ │ (index) │ Values │