Window.console in JavaScript

Window.console in JavaScript

In JavaScript, window.console or console object is under-rated with only console.log() being used most of the time. However, the console object comes with a lot of advanced features. In this article, we will be discussing the functions available on the console that can be handy at times.

In JavaScript, window.console or console object is under-rated with only console.log() being used most of the time. However, the console object comes with a lot of advanced features.

In this article, we will be discussing the functions available on the console that can be handy at times.

A deeper look into the console

Besides console.log(), there are a lot of other methods also available. You can try looking for the suggestions list in the browser’s console.

console.log()

console.log() is the most commonly used function in JavaScript to log values. It just logs/prints the value that is passed to the function.

We can also concatenate multiple values using console.log(). Simply call console.log() with multiple parameters and all the values will be concatenated.

You can even pass multiple objects and the browser’s console will show them side by side.

Following are some of the examples of concatenation with console.log:

console.table()

While console.log() can be used to print an object, we can also use console.table() to pretty print an object in the form of a table.

Just pass the object to print the object in a more readable format.

This is image title

Notice, how it prints the values for the nested object.

console.warn()

It is used to print warning messages in the browser’s console.

console.error()

It is used to print error messages in the console.

console.time()

This can be used to calculate the time elapsed by our code to execute.

Before starting the execution of any operation, start the timer with console.time(‘TIMER_NAME’) and after the execution of the code, end the timer with console.timeEnd(‘TIMER_NAME’).

As soon as you call the timeEnd function, the elapsed time will get printed in the console.

The timer name should be same for time() and timeEnd()

console.clear()

This command is used to clear the console.

Running the last command resulted in the console being cleared with the following message.

Thank you for reading !

JavaScript Front End Programming Web Development Development

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Top 19 Front-End Web Development Tools to Consider in 2020

In this post, we are putting curated list of top tools with key features and download links "Top 19 Front End Web Development Tools to Consider in 2020"

Top 6 Productivity Tools for Front-end Developers

Today I wanted to share with you the tools I daily use to increase my productivity as a front-end developer. 6 tools to increase your productivity as a Front-end developer.

Hire Web Developer

Looking for an attractive & user-friendly web developer? HourlyDeveloper.io, a leading web, and mobile app development company, offers web developers for hire through flexible engagement models. You can **[Hire Web...

Top 9 Open source JavaScript frameworks for front-end web development

About a decade ago, the JavaScript developer community began to witness fierce battles emerging among JavaScript frameworks. In this article, I will introduce some of the most well-known of these frameworks. And it's important to note that these are all open source JavaScript projects, meaning that you can freely utilize them under an open source license and even contribute to the source code and communities.

How to Master the Front-End Development

Learn how to focus your skills to become a master at front-end development. How to Master the Front-End Development. A few years back doing front-end work, especially on the web, was rather simple compared to the back-end where all the app logic used to reside. Nowadays, that has changed. Front-end development has evolved thanks to powerful frameworks and libraries supported by the evolution of the browsers and their respective APIs.