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)
- })
- }
- const calcNum = async() => {
- count = await calc2();
- count = await calc1();
- console.log(count)
- }
- calcNum();
|