/ / timestamp
function a(wait,times){
  var old = 0;
  while(times>0) {var now = Date.now();
    if(now-old>=wait)
    {
      console.log(now);
      times--;
      old =now;
    }
  }
}
a(1000.5);
//setTimeOuts()
function b(wait,times){
  for(let i=0; i<times; i++){setTimeout(() = >{
      console.log(i);
    },i*wait);
  }
}
b(1000.5);
Copy the code