Created
January 25, 2017 13:00
-
-
Save solominh/f8c6f8be918ba6a3ce4742c4ac264250 to your computer and use it in GitHub Desktop.
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
var promise1 = new Promise((resolve, reject) => { | |
setTimeout(() => { | |
console.log('Begin resolve promise 1') | |
resolve('First') | |
console.log('End resolve promise 1') | |
}, 4000) | |
}) | |
var promise2 = new Promise((resolve, reject) => { | |
setTimeout(() => { | |
console.log('Begin resolve promise 2') | |
resolve(promise1) | |
console.log('End resolve promise 2') | |
}, 2000) | |
}) | |
async function doSomething() { | |
console.log('Wait promise 2') | |
let value = await promise2; | |
console.log('End wait promise 2') | |
console.log('Value=', value); | |
} | |
doSomething() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment