What is Console Log?

Console Log

Console.log() is used to print messages to the console of web browsers. It is generally used when testing whether a function is working on the Javascript side.


When the operation is performed in conditional structures such as if else, switch case or for loops in Javascript codes on the pages, it can be tested whether the function works by printing a message to the console of the browser with the help of console.log.

For example, when the code below runs in a web browser, it prints an OK message to the browser’s console.

<button id="btn">Button</button>

    document.getElementById('btn').onclick = function () {

Google Chrome Console:

Console Log