JavaScript/sleep:修订间差异

来自康健生活
Kangkk​(留言 | 贡献)
Kangkk​(留言 | 贡献)
第52行: 第52行:
Promise {<pending>}
Promise {<pending>}
Do other things, Wed Jun 24 2020 23:42:31 GMT+0800 (中国标准时间)
Do other things, Wed Jun 24 2020 23:42:31 GMT+0800 (中国标准时间)
</pre>}}}}
{{leftrightflex|<syntaxhighlight lang="javascript">
function sleep (time) {
  return new Promise((resolve) => setTimeout(resolve, time));
}
async function usetest() {
  var temple=await sleep(1000);
  console.log('mark~');
  return temple
}
usetest();</syntaxhighlight>|{{consoleout|<pre>
Promise {<pending>}
mark~
</pre>}}}}
</pre>}}}}


{{unknown}}
{{unknown}}