Last active
May 4, 2019 11:32
-
-
Save iamlucianojr/7faa865e91e830a3470ed7a060dae62b 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
async function functionName (arguments) { | |
// Do something asynchronous | |
} | |
const functionName = async (arguments) => { | |
// Do something asynchronous | |
} | |
jeffBuysCake('black forest') | |
.then(partyAsPlanned) | |
.catch(buyCakeYourself) // Grumble Grumble... #*$% | |
const promise = jeffBuysCake('black forest') | |
.then(cake => console.log(cake)) | |
.catch(nocake => console.log(nocake)) | |
const jeffBuysCake = cakeType => { | |
return new Promise((resolve, reject) => { | |
// Do something here | |
}) | |
} | |
const jeffBuysCake = cakeType => { | |
return new Promise((resolve, reject) => { | |
setTimeout(()=> { | |
if (cakeType | |
- = 'black forest') { | |
resolve('black forest cake!') | |
} else { | |
reject('No cake 😢') | |
} | |
}, 1000) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment