avatar
Articles
54
Tags
28
Categories
6
📝Home
📱Work
📬Contact
🧑‍💻About
👋Harry BlogAsync Await Promise Demo Back to Home
Search
📝Home
📱Work
📬Contact
🧑‍💻About

Async Await Promise Demo

Created2020-02-16|Updated2025-09-27|DevelopmentFrontend
|Post Views:

Video: https://harrywork.com/cos/site/blog/video/2020/promise.mp4

const delay = ms=>new Promise(r=>setTimeout(r,ms));
async function run(){
await delay(2000); console.log('step1');
await delay(1000); console.log('step2');
await delay(500); console.log('step3');
}
run();
Author: Harry
Link: https://harrywork.com/blog/p/50160/
Copyright Notice: All articles on this blog are licensed under CC BY-NC-SA 4.0 unless otherwise stated.
javascript
Thanks
  • Paypal
    Paypal
  • Wechat
    Wechat
cover of previous post
Previous
PHP ZipArchive Add File Path Handling
Control internal directory structure when adding files to a ZipArchive.
cover of next post
Next
Axios Form URL Encoded Post
Submit data as application/x-www-form-urlencoded using Axios transformRequest.
Related Articles
2015-07-15
pageX clientX screenX Differences
Distinguish between screen, page, and client mouse/touch coordinate properties in browsers.
2016-08-15
JS Detect Device and Platform via UserAgent
Legacy userAgent pattern matching to redirect mobile users; prefer feature detection today.

Comments
avatar
Harry
Articles
54
Tags
28
Categories
6
About
Recent Posts
ComfyUI workflow fails via API but succeeds in UI2025-04-18
Edit Video Duration Metadata2025-03-16
FFmpeg Chinese Garbled Text (Windows)2024-10-15
Canvas Curved Rainbow Text (Vue.js)2024-05-25
WeChat Mini Program Font Android Issue2024-05-15
© 2017 - 2025 By Harry
Search
Loading Database