If I have the following callback function:
a(function () {
b()
})
my understanding is that a would be executed first, then b once a is finished
But generally in programming, you pass parameters to a function within the parantheses right? So in this function, it seems as though you are passing
function () {
b()
}
to the function a as an argument. So according to what I know about programming, a should execute with all of that as an argument right?
Yet according to what I know about callbacks, it means instead, that all of that executes after the a function executes. Can you see the contradiction? Also, then wouldn't the function a be executing without parameters?
Do parameters just work differently in javascript. By default, does all the stuff in the parentheses execute after the function itself?
function myCallback () { b(); }; a(myCallback);It is just a reference, it does not execute it.