SOURCE

Promise.all = function(promsieArr){
    const promises = Array.from(promsieArr)
    const values = []
    var count = 0
    return new Promise((res,rej)=>{
        promises.forEach((p,index)=>{
            Promise.resolve(p).then(value=>{
                values[index] = value
                count++
                if(promises.length === count){
                    res(values)
                }
            },reject=>{
                rej(reject)
            })
        })
    })
}
const a = new Promise((res,rej)=>{
    res('ok')
})
const b = new Promise((res,rej)=>{
    res('123')
})
let c = Promise.all([a,b])
console.log(c)
console 命令行工具 X clear

                    
>
console