Promise.all0 = function(promises){
return new Promise((reslove, reject)=>{
const len = promises.length;
let arry_put = new Array(len);
j = 0;
for(var i = 0; i<len; i++){
Promise.resolve(promises[i]).then(res=>{
arry_put[j] = res;
j++;
if(j == len){
return reslove(arry_put);
}
}),(reason)=>{
return reject(reason)
}
}
})
}
let p1 = Promise.resolve(“1”)
let p2 = Promise.resolve(“2”)
Promise.all0([p1,p2]).then(res=>{
console.log(res)
})