2016-06-12 10 views

答えて

3

Chromeコンソールでをデバッグしていません。あなたはをChromeデバッガでデバッグします。また、デバッガのブレークポイントで停止した場合は、コンソールを使用してスコープ内変数の値を割り当てて変更することができます。

例えば

、オープンのdevのツールとのコメントを読んで、このコードを実行:あなたは別のローカル変数の値を再定義したいと思う場所

function foo() { 
 
    var bar = 42; 
 
    // Normally, you don't have to use a hardcoded breakpoint like 
 
    // the one that follows, you can set a breakpoint from within the 
 
    // debugger just by navigating to the line of code and clicking in 
 
    // the left-hand gutter. But in Stack Snippets the easiest way to 
 
    // do one is to use the debugger statement: 
 
    debugger; 
 
    // Now, when stopped on the breakpoint, type this in the console: 
 
    // bar = 67; 
 
    // ...and press Enter. 
 
    // Then hit the arrow button to allow the script to continue 
 
    console.log(bar); // ...and this will log 67 instead of 42. 
 
} 
 
foo();

2

は、ブレークポイントを設定してみてください1。その後、そのスコープ内のすべてのデータにアクセスできます。

これは私が2回目に13をログに記録して欲しいもの

enter image description here

+0

を助けるかもしれません。 – footoss

+0

2回目は、あなたがそのスコープにいるときに必要なだけ多くのconsole.logステートメントを書くことができるということです。それでも13が表示されます。コードをもう一度実行しているときにもう一度13としてログに記録する場合は、変数を13に再設定してください – pshirishreddy