Skip to content

Instantly share code, notes, and snippets.

@hcmn
Created July 17, 2012 13:51
Show Gist options
  • Save hcmn/3129499 to your computer and use it in GitHub Desktop.
Save hcmn/3129499 to your computer and use it in GitHub Desktop.
JQuery: Checking for existence & type of callback
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');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment