Created
November 17, 2015 20:31
-
-
Save alexbaumgertner/236ef2e6534a1cf17cb8 to your computer and use it in GitHub Desktop.
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
// 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