From 0a64b1d05d39015d8a2d37a06c1bc8ce14bf9b73 Mon Sep 17 00:00:00 2001 From: ZYSzys <17367077526@163.com> Date: Fri, 21 Sep 2018 00:09:50 +0800 Subject: [PATCH 1/2] lib: change abstract equal to strict equal --- lib/console.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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'); From 05ab37f730e149a814fd7c4a7b9930fdd88aec7b Mon Sep 17 00:00:00 2001 From: ZYSzys <17367077526@163.com> Date: Sat, 22 Sep 2018 18:25:18 +0800 Subject: [PATCH 2/2] test: console.table when `null` in data --- test/parallel/test-console-table.js | 9 +++++++++ 1 file changed, 9 insertions(+) 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 │