123456789101112131415161718192021 |
- let count = 2;
- const calc1 = () => {
- return new Promise((res, rej) => {
- setTimeout(() => { count = count + 1; res(count) }, 2000)
- })
- }
- const calc2 = () => {
- return new Promise((res, rej) => {
- setTimeout(() => { count = count * 2; res(count) }, 3000)
- })
- }
- calc2().then(result => {
- count = result;
- calc1().then(result => {
- count = result;
- console.log(count);
- })
- })
|