问答题793/1530【Promise第27题】下面代码的输出是什么?

1 2function runAsync(x) { 3 const p = new Promise(r => 4 setTimeout(() => r(x, console.log(x)), 1000) 5 ); 6 return p; 7} 8function runReject(x) { 9 const p = new Promise((res, rej) => 10 setTimeout(() => rej(`Error: ${x}`, console.log(x)), 1000 * x) 11 ); 12 return p; 13} 14Promise.race([runReject(0), runAsync(1), runAsync(2), runAsync(3)]) 15 .then(res => console.log("result: ", res)) 16 .catch(err => console.log(err)); 17
难度:
2022-01-09 创建

赞赏支持

预览

题库维护不易,您的支持就是我们最大的动力!