-->
Console in JavaScript

Console in JavaScript

A Console is an object that provides access to the browser debugging console. The console object can be accessed from a global object. You can view the console with the F12 key. Let’s view some Console techniques used in JavaScript:

  • log()
  • error()
  • warn()
  • clear()
  • table()
  • count()
  • time() & timeEnd()
  • group() & groupEnd()

1. log()

The console log outputs a message to the browser web console. The console() is generally used for testing purposes. It supports all major browsers. The console accepts a single parameter.

Output :

Console log | Console in JavaScript

2. warn()

The console.warn() method writes a warning to the console. This parameter is used to hold the warning message.

Console warn

3. error()

The console.error() method writes an error message to the console. This console is useful for testing purposes.

Console error

4. clear()

The console.clear() method clears the console. It clears the console but writes a message “Console was cleared”.


Clear

5. count()

Logs the number of times that this particular call to count() has been called⁣. You can add a label that will be included in the console view. By default the label “default” will be added.

Count

6. table()

The console.table() method writes a table in the console view. The first parameter is required and must be either an object or an array, containing data to fill the table.

table

7. time() & timeEnd()

The console.time() method starts a timer in the console view. This method allows you to time certain operations in your code for testing purposes. Use the label parameter to specify which timer to end.

time

Share this post, if you have liked the blog & thanks for scrolling.

0 Response to "Console in JavaScript"

Post a Comment

Ads on article

Advertise in articles 1

advertising articles 2

Advertise under the article