console.log in html code example
Example 1: javascript console log
console.log('string');
Example 2: 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 3: javascript log to console
console.log('message1' + ' - ' + 'message2')
Example 4: javascript console.log
console.log('I want to log this so I am logging this. Calm down and log.')