Skip to content

Instantly share code, notes, and snippets.

@saiumesh535
Last active August 21, 2017 18:18
Show Gist options
  • Save saiumesh535/06930018deb1a6d1735548b587ef2002 to your computer and use it in GitHub Desktop.
Save saiumesh535/06930018deb1a6d1735548b587ef2002 to your computer and use it in GitHub Desktop.
Async Await is new form writing in JavaScript/Node 8
// for examples goto https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function
// this function will return a promise
function multiplication(a, b) {
return new Promise((resolve, reject) => {
resolve(a * b)
})
}
// whn you write async before function it allows you to return promise which was being returned from other function
async function giveMeTheAnswer(a, b) {
return await multiplication(a, b)
}
giveMeTheAnswer(2, 3229).then((result) => {
console.log("result is ", result)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment