summaryrefslogtreecommitdiff
path: root/doc/api/console.md
diff options
context:
space:
mode:
authorGus Caplan <me@gus.host>2018-01-13 13:55:19 -0600
committerGus Caplan <me@gus.host>2018-03-30 19:41:41 -0500
commit97ace0449292eab3f044158ba3787e6af5dd6f3a (patch)
treecd6150997307934e3f1998252d3465709469916b /doc/api/console.md
parent83d44bee0134e3b8b6b98bf89e1f02981d72adee (diff)
downloadandroid-node-v8-97ace0449292eab3f044158ba3787e6af5dd6f3a.tar.gz
android-node-v8-97ace0449292eab3f044158ba3787e6af5dd6f3a.tar.bz2
android-node-v8-97ace0449292eab3f044158ba3787e6af5dd6f3a.zip
console: add table method
PR-URL: https://github.com/nodejs/node/pull/18137 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'doc/api/console.md')
-rw-r--r--doc/api/console.md41
1 files changed, 41 insertions, 0 deletions
diff --git a/doc/api/console.md b/doc/api/console.md
index 55adfc1e83..72d80ab9e7 100644
--- a/doc/api/console.md
+++ b/doc/api/console.md
@@ -332,6 +332,47 @@ console.log('count:', count);
See [`util.format()`][] for more information.
+### console.table(tabularData[, properties])
+<!-- YAML
+added: REPLACEME
+-->
+
+* `tabularData` {any}
+* `properties` {string[]} Alternate properties for constructing the table.
+
+Try to construct a table with the columns of the properties of `tabularData`
+(or use `properties`) and rows of `tabularData` and logit. Falls back to just
+logging the argument if it can’t be parsed as tabular.
+
+```js
+// These can't be parsed as tabular data
+console.table(Symbol());
+// Symbol()
+
+console.table(undefined);
+// undefined
+```
+
+```js
+console.table([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }]);
+// ┌─────────┬─────┬─────┐
+// │ (index) │ a │ b │
+// ├─────────┼─────┼─────┤
+// │ 0 │ 1 │ 'Y' │
+// │ 1 │ 'Z' │ 2 │
+// └─────────┴─────┴─────┘
+```
+
+```js
+console.table([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }], ['a']);
+// ┌─────────┬─────┐
+// │ (index) │ a │
+// ├─────────┼─────┤
+// │ 0 │ 1 │
+// │ 1 │ 'Z' │
+// └─────────┴─────┘
+```
+
### console.time(label)
<!-- YAML
added: v0.1.104