Skip to content

Instantly share code, notes, and snippets.

@solominh
Created January 24, 2017 01:11
Show Gist options
  • Save solominh/b4b865d821603bd765b45a4f3e27c3a1 to your computer and use it in GitHub Desktop.
Save solominh/b4b865d821603bd765b45a4f3e27c3a1 to your computer and use it in GitHub Desktop.
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