function nestedFunction() {
console.log('nested function');
}
function firstFunction(cb) {
cb(nestedFunction());
}
function resetRouter() {
setTimeout(() => {
console.log('hello');
firstFunction(() => {
console.log('inside oye oyr');
});
}, 1000);
}
resetRouter();
This is my function . In this first reset Router is executed. Inside resetRouter after 1 second my first function is getting executed. First function takes a callback function as a param . Till here the things are clearer to me. But when the firstFunction is getting called it recieves a cb as a param , we are executing the callBackfunction and inside that callback function we are passing the nested function . So here first our nested function gets executed then the cb(callBack gets executed). So how is this being executed. Please someone explain its execution in a more clearer and easy way.