Skip to content

Instantly share code, notes, and snippets.

@cindywu
Created November 28, 2020 03:41
Show Gist options
  • Select an option

  • Save cindywu/04044f737bd41be6dc5c64d6bdc77d8f to your computer and use it in GitHub Desktop.

Select an option

Save cindywu/04044f737bd41be6dc5c64d6bdc77d8f to your computer and use it in GitHub Desktop.
passing functions as arguments javascript simplified
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