| Node.js console.table()
Node.js console.table() Method
In Node.js, console.table() method is an inbuilt application programming interface of a console module. And this is used to print the table which is constrcuted from it's parameters into the console.
And below is the syntax to use console.table() method:-
console.table(data, properties);
Here method will accpet two parameters as per define in above syntax. And below is the parameter details:-
(1)data:-This will have the tabular data. An array of each row data that contains values for each column of that specific row.
(2)properties:-his will specifies the properties for constructing the table.
When we say about the return value this will not return anything but this will print the constructed table and log it. And if it fails to parse the arguments into the table then it simply logs the arguments.
To understand this we will take an example of using console.table(). We will use the below code and create a file "ConsoleTable.js".
To get the code click Download Code
And to run the above file we use the Node.js command prompt and run the below command.
Node ConsoleTable.js
And output of above command is given below:-
We will take one more example with the table column and row value.
We have create a .js file with name ConsoleTableSample.js to get more details on console.table() method.
To get the code click here Download Code
And to run the above file we use the Node.js command prompt and run the below command.
Node ConsoleTableSample.js
And output of above command is given below:-
| | |