おはようございます。
今日DMMの予約時間を完全に勘違いしていてレッスンすっぽかしちゃったので猛烈反省してますどうもハヤトワンです。
なので今から英語で書きます。
let’s start!!
today’s javascript
//▼async functionの中でPromiseをreturn
//async functionで定義された関数内でPromiseをreturnすると、そのPromiseがそのまま返却される
//だからthen()やcatch()で処理を受けれる
async function rejectFunc() {
return Promise.reject(new Error('this is error'));
}
rejectFunc().catch(error => console.log(error.message));
//this is error
//▼async functionの中でthrow
//async functionで定義された関数内でthrowされた場合、そのthrowの値でPromise.rejectが実行される
async function throwFunc() {
throw new Error('error error error---')
}
throwFunc().catch(error => console.log(error.message));
//error error error---
//async functionはPromiseを返すだけの関数
//外部の関数からasync functionを呼ぶときはPromiseを返却する非同期関数と思ってればいい
this explain is japanese…sorry lol
and today’s English is this blog lol
I know that this blog became cut corners recently.
so too short sentence today also
ok I’ll go to toilet
have a good friday 🙂