jQueryを使わずPromiseを使いたいのですが、
Promiseがうまく動きません。
下記の書き方で
a b c
と表示させたいのですが、
b c a
と表示されてしまいます。
aの処理が終わるのを待たせたいです、
下記のソースで不足していたり間違っている場所はありますか?
<html> <head> <script> (function(){ a(); b(); c(); })(); function a(){ return new Promise(function(resolve,reject){ setTimeout(function(){ console.log("a"); return resolve; }, 500); }); } function b(){ console.log("b"); } function c(){ console.log("c"); } </script> </head> <body>test</body> </html>
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/04/26 15:28
2017/04/26 15:34
2017/04/26 15:41