1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

JavaScript, Async, Await 筆記

Posted at

async

主要用在 宣告

async function someFunction() {}

或是

someClass.someFunction(async () => {});

await

主要用在 呼叫 async method 或是 Promise 的時候,掛在前面關鍵字

const result = await someFunction();

Error handling

在執行有掛 await 的非同步方法外面包 try-catch

try {
  const result = await someFunction();
  console.log(error.result);
} catch (error) {
  console.log(error.message);
}
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?