Restoring console.log()

后端 未结 8 2391
粉色の甜心
粉色の甜心 2020-11-29 22:25

For some reason, the prototype framework (or another JavaScript code) that is shipped with Magento is replacing standard console functions, so I can\'t debug anything. Writi

相关标签:
8条回答
  • 2020-11-29 22:55

    For example,

    delete console.log
    

    would also restore console.log:

    console.log = null;
    console.log;         // null
    
    delete console.log;
    console.log;         // function log() { [native code] }
    
    0 讨论(0)
  • 2020-11-29 23:00

    Save a reference to the original console in a variable at the very start of the script and then either use this reference, or redefine console to point to the captured value.

    Example:

    var c = window.console;
    
    window.console = {
        log :function(str) {
            alert(str);
        }
    }
    
    // alerts hello
    console.log("hello");
    
    // logs to the console
    c.log("hello");
    
    0 讨论(0)
提交回复
热议问题