Skip to content

Instantly share code, notes, and snippets.

@alexbaumgertner
Created November 17, 2015 20:31
Show Gist options
  • Save alexbaumgertner/236ef2e6534a1cf17cb8 to your computer and use it in GitHub Desktop.
Save alexbaumgertner/236ef2e6534a1cf17cb8 to your computer and use it in GitHub Desktop.
// What is `callback`?
/**
* Async working method with callback
*
* @param {*} data
* @param {function} callback
*
* @returns {string}
*/
function asyncWorkingMethod(data, callback) {
// Async operation
setTimeout(function () {
// call back
callback();
}, 1000);
}
console.log('before calling asyncWorkingMethod');
var asyncWorkingMethodResult = asyncWorkingMethod({foo: 'bar'}, function () {
console.log('callback code run HERE');
});
console.log('result of asyncWorkingMethod: ', typeof asyncWorkingMethodResult);
console.log('after calling asyncWorkingMethod');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment