Console object can be accessed from any global object.
Window on browsing scopes and
WorkerGlobalScope as specific variants in workers via the property console. It’s exposed as
Window.console, and can be referenced as simply
- The most useful feature of the console is logging of text and other data. There are four categories of output you can generate, using the
console.error()methods. Each of these results in output styled differently in the log, and you can use the filtering controls provided by your browser.
- In order to calculate the duration of a specific operation, there is a
consoleobject. To start a timer, you can call the
()method, giving it a name as the only parameter. To stop the timer, and to get the elapsed time in milliseconds, just call the
- The console object also supports outputting a stack trace. This will show you the call path taken to reach the point at which you call
- In case you have so many logs that you don’t know how many times given parts of the code have been executed, there’s an API for that. The
console.count()method counts how many times it’s been called.
Let it be debugged! There are many more thing to learn, and you can find them here.