🔥 Prove me your wrong by writing Polyfill for Promise.All in JavaScript 🔥 Amazon | Apple INT QSN

preview_player
Показать описание


Рекомендации по теме
Комментарии
Автор

After learning the Promise.All try writing polyfil for Promise.allSettled() and Promise.any() and add your code here. I will check it and give my feedback.

careerwithvasanth
Автор

Amazing explanation.
Your content is gold.
Thank you for all the videos

nagambikaanguraj
Автор

This implementation will fail, if supplied promises having delay ( setTimeOut) . Since you are relying on index of forEach rather than counter

akshaykumar
Автор

Hey, this implementation will fail, if the last promise in the array has the least delay. We can use count variable to make sure that returned promise is resolving only after the last promise in the array.

function myPromiseAll(arr) {
return new Promise(function (resolve, reject) {
// count is used to make sure that returned promise gets resolved after the last promise in the array.
let count = 0;
let output = [];
arr.forEach(function (currentPromise, index) {
try {
currentPromise.then(function (data) {
output[index] = data;
count += 1;
if (count === arr.length) {
resolve(output);
}
});
} catch (err) {
reject(err);
}
});
});
}

bobbysadhwani
Автор

Please could you add a video for complete Promise implementation.

nagambikaanguraj
Автор

Please make videos on promise polyfill as well.

salonijaiswal