html console log code example

Example 1: console.log javascript

console.log(10);
console.log('You can also log numbers')

Example 2: how to log to the console javascript

console.log('What you want to log here.');

Example 3: javascript console log

console.log('string');

Example 4: display console log in HTML

(function () {
    var old = console.log;
    var logger = document.getElementById('log');
    console.log = function (message) {
        if (typeof message == 'object') {
            logger.innerHTML += (JSON && JSON.stringify ? JSON.stringify(message) : message) + '<br />';
        } else {
            logger.innerHTML += message + '<br />';
        }
    }
})();

Example 5: how to print console in javascript

console.log("message here")

Tags: