javascript printing code example

Example 1: js how to print

console.log(text);

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: how to print in javascript

//It is very esay to print!
//This how to print in Javascript!
console.log("string");

var num = 1;

console.log(num);

Tags:

Php Example