Simple question about callback functions in JavaScript

For this code:

Can you elaborate on what order everything gets executed in? For example, take

function doMath(number1,number2,callback){ if (typeof callback === “function”) { var result = callback(number1,number2); document.getElementById(“theResult”).innerHTML += (callback.toString() + “<br><br>The result is: “ + result + “<br><br>“); }


function multiplyThem(number1,number2){ var calculation = number1 * number2; return calculation; }

and call it with


What is the order in which everything gets executed? Can you go through it step by step? I'm having a little trouble visualizing how it all works. Thanks a bunch you are all super great people!

submitted by /u/LovelyLionLily
[link] [comments]

from web_design