Debugging Javascript Applications

Logging is an important ascpect to debug simple and complex applications. This helps the developer to see what's going on in the application, how it is reacting to changes, where the code is breaking etc.

The most common and standard way to log the data is log() method of console object.

But, console object has some other really intereting method to create logs like warn info error etc.

log()

It is used to output messages in console

image info

warn()

It is used to output warning messages in console.

image info

info()

It is used to output informative messages in console

image info

error()

It is used to output error messages in console.

image info

table()

It is used to console output in a nice tabular format.

image info

dir()

It is used to display object in a nice interactive manner. It let's us see the contents of child objects.

image info

tracing()

It is used to print the stack trace which helps to know and understand the code execution flow.

image info

clear()

It is used to clear the console.

image info

time()

It is used to track the time take to execute the operation.

image info

count()

It is used to count the number of times the same response is recorded.

image info

How about styling the console??

Console can be made more interactive by adding colors to it. To add styling add %c into the message. Anthing after %c will get styled by the properties specified in other arguements.

image info