I'm trying to understand why its necessary to pass a function as an argument in order to be utilized as a callback function. What is the difference if I simply call the function directly within the parent function.
http://jsfiddle.net/7Lsafchu/5/
function main(statement, callback) {
$("body").append("Statement: " + statement + "\n");
callback();
}
function anyFunction() {
$("body").append("<p>I'm writing to a wall</p>");
}
main("This is test 1",anyFunction);
function main2(statement, callback) {
$("body").append("Statement: " + statement);
anyFunction2();
}
function anyFunction2() {
$("body").append("<p>I'm writing to a wall Again</p>");
}
main2("This is test 2");