overriding console.log in JS -- JS

Example

Example 1

Code 

console.log = function()
{
    console.log("Hello");
}

console.log();

Output

overriding console.log in JS -- JS_第1张图片

Example 2

Code

//Save original reference
var originalConsole = console;
//Override
console = {};
console.log = function()
{
    //According to MDN the console.log function can receive a variable number of params
    for(var i=0; i

Output

overriding console.log in JS -- JS_第2张图片

你可能感兴趣的:(javascript,前端,vue.js)