DEV Community

Cover image for Debugging Javascript Applications
Diksha Goyal
Diksha Goyal

Posted on

Debugging Javascript Applications

Logging is an important aspect 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, the console object has some other really interesting method to create logs like warn info error etc.

log()

It is used to output messages in the console

console.log()

warn()

It is used to output warning messages in the console.

console.warn()

info()

It is used to output informative messages in the console

console.info()

error()

It is used to output error messages in the console.

console.error()

table()

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

console.table()

dir()

It is used to display objects in a nice interactive manner. It lets us see the contents of child objects.

console.dir()

tracing()

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

console.trace()

clear()

It is used to clear the console.

console.clear()

time()

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

console.time()

count()

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

console.count()

How about styling the console??

The console can be made more interactive by adding colors to it. To add styling add %c into the message. Anything after %c will get styled by the properties specified in other arguments.

styles

This blog was initially published here

Top comments (0)