Back to: JavaScript Tutorial For Beginners and Professionals
JavaScript Console Object
In JavaScript, a console is an object that provides the access to the web browser’s debugging console. The console object is a property of the window object. The console object can be accessed with either Window.Console or Console i.e.: Window.Console.Log() or Console.Log()
The Console object is present only if there is a debugging tool supported by the browser. console.log() is used to display JavaScript values in the console window under the debugging tool of the browser. It is used to write log messages at runtime. For a better understanding, please have a look at the below example:
<html> <body> <h1>Debugging</h1> <script> a = 15; b = 16; c = a + b; console.log(c); </script> </body> </html>
Methods of Console Objects in JavaScript:
The JavaScript console object provides several different methods:
- assert()
- clear()
- count()
- countReset()
- debug()
- dir()
- dirxml()
- error()
- group()
- groupCollapsed()
- groupEnd()
- info()
- log()
- table()
- time()
- timeEnd()
- timeLog()
- trace()
- warn()
We will look at all these methods one by one in our next article.
In the next article, I am going to discuss JavaScript Console Assert() Method with Examples. Here, in this article, I try to explain JavaScript Console Object. I hope this JavaScript Console Object article will help you with your need. I would like to have your feedback. Please post your feedback, question, or comments about this article.