Skip to content

Instantly share code, notes, and snippets.

@hansfpc
Created August 4, 2017 05:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hansfpc/9aaea62a131550e59067a095b95ce122 to your computer and use it in GitHub Desktop.
Save hansfpc/9aaea62a131550e59067a095b95ce122 to your computer and use it in GitHub Desktop.
Callback example for dummies
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