-
-
Save Bijesse/ed8a8653888a27c19d18f2bfcc17096b to your computer and use it in GitHub Desktop.
Blast off, callback ex // source http://jsbin.com/bidoca
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>Blast off, callback ex</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
var blastOff = function(destination) { | |
console.log("Blasting off for " + destination + "!"); | |
} | |
function makeRocketLauncher(rocketName, blastOffCallback) { | |
return function(planet) { | |
console.log("Launching " + rocketName); | |
console.log("3... 2... 1..."); | |
blastOffCallback(planet); | |
}; | |
} | |
var launchViking = makeRocketLauncher("Viking", blastOff); | |
// var launchMariner = makeRocketLauncher("Mariner", blastOff); | |
launchViking("venus"); | |
//launchMariner(); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript"> var blastOff = function(destination) { | |
console.log("Blasting off for " + destination + "!"); | |
} | |
function makeRocketLauncher(rocketName, blastOffCallback) { | |
return function(planet) { | |
console.log("Launching " + rocketName); | |
console.log("3... 2... 1..."); | |
blastOffCallback(planet); | |
}; | |
} | |
var launchViking = makeRocketLauncher("Viking", blastOff); | |
// var launchMariner = makeRocketLauncher("Mariner", blastOff); | |
launchViking("venus"); | |
//launchMariner();</script></body> | |
</html> |
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
var blastOff = function(destination) { | |
console.log("Blasting off for " + destination + "!"); | |
} | |
function makeRocketLauncher(rocketName, blastOffCallback) { | |
return function(planet) { | |
console.log("Launching " + rocketName); | |
console.log("3... 2... 1..."); | |
blastOffCallback(planet); | |
}; | |
} | |
var launchViking = makeRocketLauncher("Viking", blastOff); | |
// var launchMariner = makeRocketLauncher("Mariner", blastOff); | |
launchViking("venus"); | |
//launchMariner(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment