जब एक फंक्शन को दूसरे फंक्शन में पास किया जाता है, तो इसे कॉलबैक फंक्शन कहा जाता है। यह इस फंक्शन पर जाता है फिर पास किए गए फंक्शन को कॉल करने के लिए।
उदाहरण
कॉलबैक फंक्शन्स के साथ काम करना सीखने के लिए निम्नलिखित कोड चलाएं:
<html> <head> <script> var callback = function(myCallback) { setTimeout(function() { myCallback(); }, 5000); }; document.write("First is displayed"); document.write("<br>Second is displayed"); callback(function() { document.write("This is Callback function"); }); document.write("<br>Last is displayed"); </script> </head> </html>