SOURCE

// 参考文档:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise/all

const promise1 = 'value1';
const promise2 = Promise.resolve('value2');
const promise3 = new Promise((resolve, reject) => resolve('value3'));
const promise4 = Promise.reject('error');

/**
 * 灵雀云前端面试题:实现 Promise.all 函数
 */
Promise.all = function(arg){
  
}


// 期望以下测试用例能够正确运行
Promise.all([promise1, promise2])
  .then((result)=> console.log(result))

Promise.all([promise2, promise3, promise1])
  .then((result)=> console.log(result))

Promise.all([promise2, promise3, promise4])
  .then((result)=> console.log(result))
  .catch((error) => console.log(error))

/*
** 输出结果
["value1", "value2"]
["value2", "value3", "value1"]
"error"
*/
console 命令行工具 X clear

                    
>
console