what is callback in JavaScript

JavaScript is asynchronous. It’s means if you send HTTP request and on next line you execute something, it will not wait for the HTTP Response. For make this thing work, there is a strategy in JavaScript that is called Callback.

$.get(“demo_test.asp”, function(data, status){
// This code will execute after response received.
});

This is how Callback works in JavaScript.  For reference read these articles

https://developer.mozilla.org/en-US/docs/Glossary/Callback_function

https://developer.mozilla.org/en-US/docs/Mozilla/js-ctypes/Using_js-ctypes/Declaring_and_Using_Callbacks

One thought on “what is callback in JavaScript”

Leave a Reply

Your email address will not be published. Required fields are marked *