we can use various methods of console in javascript to debug our code. Previously, if we wanted to debug JavaScript, alert methods were mostly used however they were very annoying. Below code snippet shows available methods to print debug statements in chrome console.
1
<script>
2
console.error('Google chrome dev tools - error');
3
console.warn('Google chrome dev tools - warn');
4
console.info('Google chrome dev tools - info');
5
console.debug('Google chrome dev tools - debug');
6
console.log('Google chrome dev tools - log');
7
</script>
Below is output, how its displayed in chrome
As shown in above image, different log levels of console method printed in different color. error log level even prints complete stack trace of methods showing origin of error.
No comments:
Post a Comment