Help us understand the problem. What is going on with this article?

async(Promise)のthen()内の関数の引数の省略

備忘録として書き記す。

nuxt.jsのコードを追っていたところ下記の部分で引っかかる。

.nuxt/client.js
// Create and mount App
createApp().then(mountApp).catch(errorHandler)

コードの内容から察するにmountAppにはcreateAppの結果が引数として渡されているように見えるので実際に確かめてみた。

main.js
const first = async () => {
  return 'first'
}

const second = (arg) => {
  console.log('second')
  console.log(arg)
}

// then内の関数に自動的に引数が渡される
first().then(second)
// second
// first

// 省略しないパターン
first().then((f) => second(f))

どなたかこのような振る舞いの名称や公式で記載されているページをご存知であれば、コメントで教えていただけると幸いです。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした