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
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 .