Home > Back-end >  Javascript console.log not working inside function in debugger
Javascript console.log not working inside function in debugger

Time:06-01

To debug some concepts I run this in Chrome Console:

what = function(){ 
    let value = 5
    try { 
        wrong(); 
    } catch(e) { 
        console.log('bad'); 
        value  = 1
    }
    return value
}
what()
# returns 6

Works as expected, except console.log('bad') never happens.

obviously the fact that value = 6 and not 5 is proof that block is called.

Why does console.log just get skipped in the console? I'm pretty sure I've injected JS into apps where the console.log works so this is probably a setting in the console window itself. Firefox's behavior is the same.

CodePudding user response:

My best guess, since it isn't working on either platform, is that it is an extension that is blocking it -- from another stackoverflow post, it may be firebug lite or you accidentally disabled it through your filters.

If none of this works, I suggest trying out a guest window and seeing if it works there.

I can not reproduce this on my own machine as well as others: Chrome 102.0.5005.61 (Official Build) (64-bit) (cohort: 102_win_control)

CodePudding user response:

It is working! Remove the last line and it will work! If it again did not worked then it is might blocking by an extension

  • Related