- time() and timeEnd()
- group() and groupEnd()
Let’s look at all these methods one by one.
Mainly used to log(print) the output to the console. We can put any type inside the log(), be it a string, array, object, boolean etc.
Used to log error message to the console. Useful in testing of code. By default the error message will be highlighted with red color.
Used to log warning message to the console. By default the warning message will be highlighted with yellow color.
Used to clear the console. The console will be cleared, in case of Chrome a simple overlayed text will be printed like : ‘Console was cleared’ while in firefox no message is returned.
console.time() and console.timeEnd()
In the above code sample, we can see that the label is ‘abc’ which is same for both the time() and the timeEnd() method. If we increase the amount of code inside the block defined by these methods, then the time will increase. It is also worth remembering that the time returned to the console will be in milliseconds and might be different each time we refresh the page.
This method allows us to generate a table inside a console. The input must be an array or an object which will be shown as a table.
This method is used to count the number that the function hit by this counting method.
console.group() and console.groupEnd()
group() and groupEnd() methods of the console object allows us to group contents in a separate block, which will be indented. Just like the time() and the timeEnd() they also accepts label, again of same value.
- HTML | DOM console.log() Method
- HTML | DOM console.groupEnd() Method
- HTML | DOM console.timeEnd() Method
- HTML | DOM console.warn() Method
- HTML | DOM console.assert( ) Method
- HTML | DOM console.info() Method
- HTML | DOM console.group() Method
- HTML | DOM console.clear() Method
- HTML | DOM console.trace() Method
- HTML | DOM console.error() Method
- HTML | DOM console.groupCollapsed() Method
- HTML | DOM console.time() Method
- HTML | DOM console.table() Method
- HTML | DOM console.count() Method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.