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

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

    Usually we sent variables to functions . Suppose you have task where the variable needs to be processed before being given as an argument - you can use callback .

    function1(var1, var2) is the usual way .

    What if I want var2 to be processed and then sent as an argument? function1(var1, function2(var2))

    This is one type of callback - where function2 executes some code and returns a variable back to the initial function .

提交回复
热议问题