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

后端 未结 30 1541
时光说笑
时光说笑 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:35

    Plain and simple: A callback is a function that you give to another function, so that it can call it.

    Usually it is called when some operation is completed. Since you create the callback before giving it to the other function, you can initialize it with context information from the call site. That is why it is named a call*back* - the first function calls back into the context from where it was called.

提交回复
热议问题