forked from chinchang/konsole.table
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.js
More file actions
30 lines (23 loc) · 816 Bytes
/
example.js
File metadata and controls
30 lines (23 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var table = require('./index');
// Array of objects
console.table([{a:1, b:2, c: function(){}}, {a:"foo", b:false, c:undefined}]);
// Array of arrays
var people = [["John", "Smith"], ["Jane", "Doe"], ["Emily", "Jones"]]
console.table(people);
// Limiting columns
console.table([
{ firstName: 'Kushagra', lastName: 'Gour' },
{ firstName: 'John', lastName: 'Doe' }
], ['firstName']);
// Passing object instead of array
function Person(firstName, lastName, age) {
this.firstName = firstName;
this.lastName = lastName;
this.age = age;
}
var family = {};
family.mother = new Person("Susan", "Doyle", 32);
family.father = new Person("John", "Doyle", 33);
family.daughter = new Person("Lily", "Doyle", 5);
family.son = new Person("Mike", "Doyle", 8);
console.table(family, ["firstName", "lastName", "age"]);