2

So as I mentioned in the title - why this two Promises are resolving in the same time? Shouldn't const a wait 1000 ms for resolving p and then const b resolve after that in 1000 ms as well?

const p = new Promise(res => {
  setTimeout(() => res(10), 1000)
})
const p1 = new Promise(res => {
  setTimeout(() => res(100), 1000)
})

const resolve = async () => {
  const a = await p;
  console.log(a)
  const b = await p1;
  console.log(b)
}

resolve();

They both do console.log in the same time. I expect:

wait 1000ms
console.log(10)
wait 1000ms
console.log(100)
mcfly21
  • 31
  • 3

0 Answers0