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

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

赞赏支持

预览

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