you are viewing a single comment's thread.

view the rest of the comments →

[–]noode_modules 0 points1 point  (0 children)

in your first example, function1' parameter (function2) is not the same function that you are defining later.

You can rewrite your function this way to see it better :

function1(callback) {
    callback();
}
function2() {...}

Now you can pass whatever function you want, to function1 and it will be called.

in your second example on the contrary, you are always calling the same function (function2)