DEV Community

Cover image for Difference Type of Console in JavaScript
Madhusudhan
Madhusudhan

Posted on

Difference Type of Console in JavaScript

Hi Every one Welcome back. This time I have come back with types of console in JavaScript. well the beginners think there is one type of console.log() but there are more than one types like

1.console.log()
2.console.info()
3.console.clear()
4.console.error()
5.console.warn()
6.console.assert()
7.console.count()
8.console.trace()
9.console.table()
10.console.time() and console.timeEnd()
11.console.group() , console.groupEnd() and console.grupCollapsed()

this many types of console are there let us start

1.console.log()
As a new programmer you have learned to display the program from console.log() and console.log() displays the mathematical expressions.

console.log('name');          

console.log(1);

console.log(true);

console.log(['a','b','c','d']);

console.log({ one: 1, two: 2, three: 3 });`
Enter fullscreen mode Exit fullscreen mode

you can check out the output it will make you pratice.

2.console.info
it is same has console.log() but little difference. it use to display important message to console.

console.info('This is information');

console.info({firstName : 'abc', lastName : 'xyz'});

console.info([1,2,3,4,5]);
Enter fullscreen mode Exit fullscreen mode

3.console.clear()
It is as simple as the name. it used to clear the mess in the console

console.clear();
Enter fullscreen mode Exit fullscreen mode

4.console.error()

the heading only tell you what it will do. this method was developed by debugging only.

console.error('Error on line 1');
Enter fullscreen mode Exit fullscreen mode

5.console.warn()

this method is used to display the warning message when any thing is going wrong.

console.warn("This is a Warning");
Enter fullscreen mode Exit fullscreen mode

other six will share infomation on other post.

Top comments (0)