Created
January 16, 2019 14:41
-
-
Save ms314006/5bde5ca123455e9abe4caf6fc3ba675b 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
const newPromise = new Promise((resolve, reject)=>{ | |
setTimeout(()=>{resolve('changed')}, 3000) | |
}).then((data)=>{ | |
console.log(data) | |
//第二個Promise | |
return new Promise((resolve, reject)=>{ | |
setTimeout(()=>{resolve('last ' + data)},2000) | |
}).then((lastData)=>{ | |
return lastData | |
}) | |
}).then((data)=>{ | |
console.log(data) // 'last changed' | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment