How to explain callbacks in plain english? How are they different from calling one function from another function?

后端 未结 30 1515
时光说笑
时光说笑 2020-11-22 11:13

How to explain callbacks in plain English? How are they different from calling one function from another function taking some context from the calling function? How can thei

30条回答
  •  隐瞒了意图╮
    2020-11-22 11:16

    A metaphorical explanation:

    I have a parcel I want delivered to a friend, and I also want to know when my friend receives it.

    So I take the parcel to the post office and ask them to deliver it. If I want to know when my friend receives the parcel, I have two options:

    (a) I can wait at the post office until it is delivered.

    (b) I will get an email when it is delivered.

    Option (b) is analogous to a callback.

提交回复
热议问题