Recently, when I looked at the principle of promise implementation, I found that there was a special parameter in the promise.all method that I didn't understand.

var p3 = new Promise ((resolve, reject) = > {
setTimeout (resolve, 100, "foo");
});

p3 returns a promise object, and the value taken with the then method is" foo", what is the implementation flow? I hope there are bosses who can popularize science.

Mar.18,2021

does this make sense

var p3 = new Promise((resolve, reject) => {
  setTimeout(() => {
    resolve('foo');
  }, 100);
});

setTimeout can have more than two parameters

Menu