Created
April 17, 2015 21:44
-
-
Save alexklibisz/10c76d5a50c8c0c3307f to your computer and use it in GitHub Desktop.
Simple Javascript callback function example
This file contains 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
//predefined callback | |
a("Hello world", b); | |
//custom callback | |
a("Hello world", function(s) { | |
console.log(s + ", how are you?"); | |
}); | |
function a(s, callback) { | |
callback(s); | |
} | |
function b(s) { | |
console.log(s + "!!!"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment