Created
August 4, 2017 05:50
-
-
Save hansfpc/9aaea62a131550e59067a095b95ce122 to your computer and use it in GitHub Desktop.
Callback example for dummies
This file contains 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
let getUser = (id, callback) => { | |
let user = { id, name: 'hans'}; | |
setTimeout( () => callback(user), 3000); | |
}; | |
getUser(31, (userObject) => console.log(userObject) ); | |
// Prints { id: 31, name: 'hans' } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment