Skip to content

thenable

Posted on:June 5, 2023 at 04:43 AM

the parameter of Promise.resolve can also be a Promise


const original = Promise.resolve(33);
const cast = Promise.resolve(original);
cast.then((value) => {
  console.log(`value: ${value}`);
});
console.log(`original === cast ? ${original === cast}`);

Promise.race1=(array) => {
return new Promise((r, reject) => {
array.forEach(promise => {
Promise.resolve(promise).then(r, reject);
})
})
}