function shoutOutTo(param1, param2, callback) {
alert('Holla, holla, holla!\nGiving a shoutOut to ' + param1);
callback();
}
theHomie('Buster', function() {
alert('Finished eating my sandwich.');
});
function mySandwich(param1, param2, callback) {
alert('Started eating my sandwich.\n\nIt has: ' + param1 + ', ' + param2);
if (callback) {
callback();
}
}
mySandwich('ham', 'cheese');
function mySandwich(param1, param2, callback) {
alert('Started eating my sandwich.\n\nIt has: ' + param1 + ', ' + param2);
if (callback && typeof(callback) === "function") {
callback();
}
}
mySandwich('ham', 'cheese', 'vegetables');
Understand JS Callbacks and Use Them - JSIsSexy Callback Functions in JS Refactoring Out of Callback Hell Understanding Error-first Callbacks in NodeJS