Taking you to the next exercise in seconds...
Want to create exercises like this yourself? Click here.
Note - Having trouble with the assessment engine? Follow the steps listed here
No hints are availble for this assesment
Answer is not availble for this assesment
Please login to comment
2 Comments
Please elaborate what is meant by
Upvote Share"An async function returns immediately and on completion, it calls back the function provided as an argument."?
Whenever we execute a usual function or method, it does not go to next step untill the function has finished. Right? Such methods are called synchronous.
But when you need to do some work in background you would require async or asynchronous functions. When you call an async function the control goes to the next step or you can say the function returns immediately. The function starts to work in background.
Say, you want to create a znode in zookeeper, if you call an async API function of zookeeper, it will create znode in background while the control goes immediately to the next step. The async functions are very useful for doing work in parallel.
Now, if something is running in background and you want to be notified when the work is done. In such cases, you define a function which you want to be called once the work is done. This function can be passed as an argument to the async API call and is called a callback.
5 Upvote Share