Console access to Javascript variables local to the $(document).ready function

后端 未结 8 1241
盖世英雄少女心
盖世英雄少女心 2021-01-03 23:27

How can I access some variables inside

$(document).ready(function(){
    var foo=0;
    var bar = 3;
});

from Google chrome console? If I

8条回答
  •  天命终不由人
    2021-01-03 23:36

    Put a breakpoint with the debugger. You'll get full access to them when the debugger will stop.

    Other answers telling you to put them in the global scope are bad. Don't use bad practices just because you don't know how to use the right tools.

提交回复
热议问题