2020-02-23 22:53:45 +00:00
|
|
|
const add = (a, b) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
setTimeout(() => {
|
|
|
|
resolve(a + b)
|
|
|
|
}, 2000)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// add(1, 2).then((sum) => {
|
|
|
|
// console.log(sum)
|
|
|
|
//
|
|
|
|
// add(sum, 5).then((sum2) => {
|
|
|
|
// console.log(sum2)
|
|
|
|
// }).catch((e) => {
|
|
|
|
// console.log(e)
|
|
|
|
// })
|
|
|
|
// }).catch((e) => {
|
|
|
|
// console.log(e)
|
|
|
|
// })
|
2020-02-15 18:59:45 +00:00
|
|
|
|
2020-02-23 22:53:45 +00:00
|
|
|
add(1, 1).then((sum) => {
|
|
|
|
console.log(sum)
|
|
|
|
return add(sum, 4)
|
|
|
|
}).then((sum2) => {
|
|
|
|
console.log(sum2)
|
|
|
|
}).catch((e) => {
|
|
|
|
console.log(e)
|
2020-02-15 18:59:45 +00:00
|
|
|
})
|