Created
November 28, 2020 03:41
-
-
Save cindywu/04044f737bd41be6dc5c64d6bdc77d8f to your computer and use it in GitHub Desktop.
passing functions as arguments javascript simplified
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 printVariable(variable) { | |
| console.log(variable) | |
| } | |
| function newfunc(name, callback) { | |
| callback(name) | |
| } | |
| /* function callback(x) { | |
| console.log("Hello " + x) | |
| } */ | |
| function printName(name, callback) { | |
| callback("Hello " + name) | |
| } | |
| // newfunc("cindy", callback) | |
| newfunc("Cindy", printVariable) | |
| printName("Cindy", function(variable) { | |
| console.log(variable) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment