Last active
August 21, 2017 18:18
-
-
Save saiumesh535/06930018deb1a6d1735548b587ef2002 to your computer and use it in GitHub Desktop.
Async Await is new form writing in JavaScript/Node 8
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
// 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