Created
January 24, 2017 01:11
-
-
Save solominh/b4b865d821603bd765b45a4f3e27c3a1 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 timer = (ms) => { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
resolve(); | |
}, ms) | |
}); | |
} | |
var promise1 = timer(4000); | |
timer(4000).then(() => { | |
console.log('Finish timer') | |
promise1.then(() => { | |
console.log('Finish promise') // log out with the same time as above log | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment