function sleep(num){ var start=(new Date()).getTime(); while ((new Date()).getTime()<start+num){}}console.log("开始")sleep(2000)console.log("结束")