Callback Functions:let me explain to you in simple words .We call the second function through first function which takes second function as argument in 1st .
function printFirstName(firstname,cb)
{
console.log(firstname);
cb("Verma");
}
function printLastName(lastname)
{
console.log(lastname);
}
printFirstName("pushan",printLastName);
Top comments (6)
There is nothing simple about callbacks.
JavaScript code is fundamentally synchronous. Callback functions can be synchronous depending on the circumstances but they often are a means towards asynchronous processing.
To understand that you have to understand the event loop.
Sometimes people just want to know that is the gist of the topic , in a very few lines. I try to provide that . Someone with little knowledge of JS can also get a idea. Full articles are available at medium etc. but I want to provide short and crisp explanation.
Thanks
Pushan
?
let me explain to you in simple words .We call the second function through first function which takes second function as argument in 1st .
I understand call backs. What I dont understand is why you’re making a post with no information, context or description what so ever except for a simple code excerpt.
Sometimes people just want to know that is the gist of the topic , in a very few lines. I try to provide that . Someone with little knowledge of JS can also get a idea. Full articles are available at medium etc. but I want to provide short and crisp explanation.
Thanks
Pushan