Created
February 10, 2020 17:06
-
-
Save accessomnath/5b19af190643be1903753abe12225782 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function tryMe (param1, param2) { | |
alert(param1 + " and " + param2); | |
} | |
function callbackTester (callback) { | |
callback (arguments[1], arguments[2]); | |
} | |
callbackTester (tryMe, "hello", "goodbye"); | |
// -------------------------------- | |
// callback function | |
function tryMe (param1, param2, param3) { | |
alert (param1 + " and " + param2 + " " + param3); | |
} | |
// callback executer | |
function callbackTester (callback) { | |
//this is the more obivous scenario as we use callback function | |
//only when we have some missing value | |
//get this data from ajax or compute | |
var extraParam = "this data was missing" ; | |
//call the callback when we have the data | |
callback(extraParam); | |
} | |
// test function | |
callbackTester (function(k) { | |
tryMe("hello", "goodbye", k); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment