Slide 7
Slide 7 text
Callback Pattern
In computer programming, a callback is a piece of executable code that is
passed as an argument to other code, which is expected to call back (execute)
the argument at some convenient time.
Wikipedia: http://en.wikipedia.org/wiki/Callback_(computer_programming)
var printFullName = function(fullName) {
console.log(fullName);
};
printFullName('Grace Hopper');
var createFullNameAndPrintIt = function(first, last, callback){
var fullName = first + ' ' + last;
callback(fullName); //Should really check if callback is a function
};
createFullNameAndPrintIt('Grace', 'Hopper', printFullName);
createFullNameAndPrintIt('Grace', 'Hopper', function(fullName){
console.log('Commander ' + fullName);
});