JavaScript | Callbacks
JavaScript callbacks can be used to process the result of async operation. Lets take a example below.
As shown in below example the callback function is used to process the response received from rest service.
Things gets complicated when we have to call more than one request on after another like second request is depending upon response of first request. This leads to callback hell. I recommend to read more on https://javascript.info/callbacks
As you chain more and more calls it becomes complicated to maintained code. This can be avoided with JavaScript Promises.
Comments
Post a Comment