What are callbacks and what is a callback hell. In this short video I provide a simple explanation to callbacks.
A Callback is a function that is passed to another function.
/*
Three ways to work with asynchronous operations in Javascript
1. Callbacks
2. Promises
3. async / await
*/
/*
Callback is a function that is passed to another function
*/
setTimeout(function () {
console.log('Done')
}, 3000)
function myFunction(param1, callback) {
// some operations
console.log(param1)
callback()
}
function myCallbackFunction() {
console.log('Ankur')
}
myFunction(123, myCallbackFunction)