I would like to create a custom callback function for a custom function and pass callback as a parameter.
function customFunction(a, b, callback) {
// Some code
}
customFunction("val1", "val2", function(){
//Code to execute after callback
});
You're almost there...
function customFunction(a, b, callback) {
// Some code
if (typeof callback === 'function') {
callback();
}
}
customFunction("val1", "val2", function(){
//Code to execute after callback
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With