You can use:
if (callback && typeof(callback) === "function") {
callback();
}
The below example is little more comprehensive:
function mySandwich(param1, param2, callback) {_x000D_
alert('Started eating my sandwich.\n\nIt has: ' + param1 + ', ' + param2);_x000D_
var sandwich = {_x000D_
toppings: [param1, param2]_x000D_
},_x000D_
madeCorrectly = (typeof(param1) === "string" && typeof(param2) === "string") ? true : false;_x000D_
if (callback && typeof(callback) === "function") {_x000D_
callback.apply(sandwich, [madeCorrectly]);_x000D_
}_x000D_
}_x000D_
_x000D_
mySandwich('ham', 'cheese', function(correct) {_x000D_
if (correct) {_x000D_
alert("Finished eating my " + this.toppings[0] + " and " + this.toppings[1] + " sandwich.");_x000D_
} else {_x000D_
alert("Gross! Why would I eat a " + this.toppings[0] + " and " + this.toppings[1] + " sandwich?");_x000D_
}_x000D_
});
_x000D_