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