简单的javascript控制台日志(FireFox)

Kev*_*own 6 javascript firefox

我正在尝试在控制台中记录值的更改(Firefox/Firefly,mac).

 if(count < 1000)
 {
  count = count+1;
  console.log(count);
  setTimeout("startProgress", 1000);
 }
Run Code Online (Sandbox Code Playgroud)

这只返回值1.它在此之后停止.

我做错了什么还是有其他影响这个的?

Ken*_*ler 10

你没有循环.只有条件声明.使用while.

var count = 1;
while( count < 1000 ) {
      count = count+1;
      console.log(count);
      setTimeout("startProgress", 1000); // you really want to do this 1000 times?
}
Run Code Online (Sandbox Code Playgroud)

更好:

var count = 1;
setTimeout(startProgress,1000); // I'm guessing this is where you want this
while( count < 1000 ) {
    console.log( count++ );
}
Run Code Online (Sandbox Code Playgroud)