2 Quick Tips when working with JS console output

tawn33y

Tony

Posted on September 23, 2020

2 Quick Tips when working with JS console output

Here are 2 quick tips you can use when working with the output from JS console:

1) Displaying data

If you are displaying arrays or objects, use console.table rather than console.log:

// try running this:

console.table([
    { firstName: 'John', lastName: 'Doe', age: 2 },
    { firstName: 'William', lastName: 'Shakespeare', age: 3 },
]);
Enter fullscreen mode Exit fullscreen mode

This will display the data in a nice tabular view as shown below:

Alt Text

2) Copying data

If you are working with Google Chrome & need to copy data from the console output, instead of manually highlighting & copying the data, you can run this:

const data = [2, 3, 4];
copy(data);
Enter fullscreen mode Exit fullscreen mode

This will copy the data to your clipboard.

NOTE: the copy command is only available on Chrome & not on the node.js env.


Have fun coding! πŸŽ‰

πŸ’– πŸ’ͺ πŸ™… 🚩
tawn33y
Tony

Posted on September 23, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Message queue with Socket.io
javascript Message queue with Socket.io

May 6, 2024

Hoisting
javascript Hoisting

December 18, 2022

Create a simple Node Server Skeleton.
javascript Create a simple Node Server Skeleton.

December 16, 2022