We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
休眠/暂停固定时间后,执行后续逻辑
function sleep(time) { } // --- console.log('now') sleep(1000) console.log('after 1 second')
The text was updated successfully, but these errors were encountered:
同步执行
function sleep(delay) { const start = (new Date()).getTime(); while ((new Date()).getTime() - start < delay) { continue; } } // --- console.log(1); sleep(1000); console.log(2);
异步执行
function sleep(delay) { return new Promise(resolve => setTimeout(resolve, delay); } // --- async function a() { console.log(1); await sleep(1000); console.log(2); } a();
Sorry, something went wrong.
No branches or pull requests
休眠/暂停固定时间后,执行后续逻辑
The text was updated successfully, but these errors were encountered: