LoginSignup
3
4

More than 3 years have passed since last update.

async/await で非同期パタトクカシーー

Last updated at Posted at 2019-09-19

async関数を2つ呼び出すと、内部のawaitが交互に処理されます。

ということで、お約束のパタトクカシーー
https://jsfiddle.net/Lhankor_Mhy/8q2k69o1/

let r = "";
let パタトクカシーー = async(str)=>{
  for ( let x of str ){
    let s = await x;
    r = r + s;
  }
}
パタトクカシーー("パトカー");
パタトクカシーー("タクシー").then( ()=>alert(r) );

この記事は、この質問にインスパイアされました。
JavaScript - javascriptのasync/awaitの挙動の得体・仕組みが分からない|teratail

3
4
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
3
4