javascript模拟sleep

function sleep(numberMillis){  
  var now=new Date();
  var exitTime=now.getTime()+numberMillis;
  while(true){
    now=new Date();
    if(now.getTime()>exitTime){
      return;
    }
  }
}

 

posted @ 2016-06-12 16:29  楊柳  阅读(210)  评论(0编辑  收藏  举报