console.log including myself. but as you know console is an object has many methods using which we can make our debug more effectively than “`console.log“`.
as you type in browser “`console“` you see a list of other methods, which will explain some of the essential methods here.
console.assert() write an error message if the assertion is false, If the assertion is true, will not write anything.
console.assert() useful when we want to conditionally write to console something.
– since its true condition will not print anything but on chrome browser, you will see undefined.
– if assertion failed will write an error on the console
console.error() output error to web console.
console.error() can be very useful for testing purposes when you want to indicate that there is something breaking within the code
console.warn() will Outputs a warning message to the Web Console. if it’s not an important issue then you can show a warning message.
note: In Chrome and Firefox, warnings have a small exclamation point icon next to them in the Web Console log.
4) console.group() & console.groupEnd()
console.group() Creates a new inline group in the Console log. will indents following console messages by an additional level, until
console.groupEnd() is called.
console.group() can be useful when you have a collection of messages you want to keep together in good order and with many level. If needed, you can also provide your group with a label.
console.table() will display in tabular method. It logs data as a table. Each element in the array/object will be a row in the table.
This method takes two parameters, tableData and tableColumns. tableData is required and should be an array/object while tableColumns is optional and is an array containing the names of the columns you want to display.
6) console.time() & console.timeEnd()
console.time() will start a timer in the web console while console.timeEnd() stops the timer and displays the result in the console
it’s seeing how long it takes your code to run. You can also pass in an optional label parameter.
console.trace() Will log a stack trace to show how the code ended up at a certain point
console.trace() can be extremely useful when you want to see a trace when your functions are being called. You can also pass in an optional label parameter
You can still use the format specifiers with all methods of console.