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 promiseでresolve実行前に次の関数が実行されてしまう

Last updated at Posted at 2018-01-05

記事のタイトルが微妙ですが、自分の備忘録であるので。
promiseチェーンを作るときに、Promise機能を持つ関数にreturnを付け忘れるとまずい。
下記の例で言うと、second内のresolveに辿り着く前にthirdが実行される。

javascriptもpromiseも雰囲気で触っているのでやばい。

first().then(() => {
})
.then(() => {
  return second();
})
.then(() => {
  return third();
})
1
0
1

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?