Debugging is an essential part of programming. As a Developer I spent some of my time fixing bugs and problems.
console object. Taking a look at the methods to get an in-depth knowledge of the debug process.
console.assert(x > y, 'Error x is not bigger than y');
console.assert() to check if evaluated expression is false. You must pass a boolean assertion to the
There are a lot of methods to log information and values to the console.
Prints a stack trace. This is useful to see where a method call starts and his cycle.
Displays Object and Array data into a friendly tabular format.
console.info('This is just a message'); console.warn('This is a warning message'); console.error('This is an error message');
Displays an information, warning or error message to the console.
console.time('timerLabel'); console.timeEnd('timerLabel'); // => 9.15ms
Starts a timer with an associated label to track how long a process takes to complete.
monitor() method to track function calls. Returns the name of the function called and the arguments.
monitorEvents(object, ['event']); monitorEvents(document.body, 'click');
monitorEvents() method to listen for events on a specified object.
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
Did you enjoyed the article ?