Skip to content

Instantly share code, notes, and snippets.

@josmas
Created September 23, 2013 19:36
Show Gist options
  • Save josmas/6675775 to your computer and use it in GitHub Desktop.
Save josmas/6675775 to your computer and use it in GitHub Desktop.
JS Callbacks
var printFullName = function(fullName) {
console.log(fullName);
};
printFullName('Grace Hopper');
var createFullNameAndPrintIt = function(first, last, callback){
var fullName = first + ' ' + last;
callback(fullName);
};
createFullNameAndPrintIt('Grace', 'Hopper', printFullName);
createFullNameAndPrintIt('Grace', 'Hopper', function(fullName){
console.log('Commander ' + fullName);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment