TGViewer
Diyorbek.dev | ๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป Diyorbek.dev | ๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป @diyorbekk_dev ยท 381 subscribers
Post #906 102
Interviewer seni diqqat qilganda ๐Ÿ˜… (Promise all)

Interviewer: Can you explain what Promise.all does in JavaScript.
Me: Okay, ๐๐ซ๐จ๐ฆ๐ข๐ฌ๐ž.๐š๐ฅ๐ฅ ๐ข๐ฌ ๐ฅ๐ข๐ค๐ž ๐ฉ๐ฎ๐ญ๐ญ๐ข๐ง๐  ๐š๐ฅ๐ฅ ๐ฒ๐จ๐ฎ๐ซ ๐ž๐ ๐ ๐ฌ ๐ข๐ง ๐จ๐ง๐ž ๐›๐š๐ฌ๐ค๐ž๐ญ. It takes an array of promises and waits for all of them to be resolved. If one promise fails, the whole thing fails.

Interviewer: How does it handle errors.
Me: If any promise in the array rejects, Promise.all immediately rejects with that error, and the remaining promises' results are ignored.

Interviewer: Can you give an example of its usage.
Me: ๐ˆ๐ฆ๐š๐ ๐ข๐ง๐ž ๐ฒ๐จ๐ฎ'๐ซ๐ž ๐ฅ๐จ๐š๐๐ข๐ง๐  ๐ฆ๐ฎ๐ฅ๐ญ๐ข๐ฉ๐ฅ๐ž ๐ข๐ฆ๐š๐ ๐ž๐ฌ ๐จ๐ง ๐š ๐ฐ๐ž๐›๐ฉ๐š๐ ๐ž. ๐˜๐จ๐ฎโ€™๐ ๐ฎ๐ฌ๐ž ๐๐ซ๐จ๐ฆ๐ข๐ฌ๐ž.๐š๐ฅ๐ฅ ๐ญ๐จ ๐ฐ๐š๐ข๐ญ ๐ฎ๐ง๐ญ๐ข๐ฅ ๐š๐ฅ๐ฅ ๐ข๐ฆ๐š๐ ๐ž๐ฌ ๐š๐ซ๐ž ๐Ÿ๐ฎ๐ฅ๐ฅ๐ฒ ๐ฅ๐จ๐š๐๐ž๐ ๐›๐ž๐Ÿ๐จ๐ซ๐ž ๐๐ข๐ฌ๐ฉ๐ฅ๐š๐ฒ๐ข๐ง๐  ๐ญ๐ก๐ž๐ฆ.

Interviewer: What happens if the array passed to Promise.all is empty?
Me: If the array is empty, Promise.all resolves immediately with an empty array, like ๐š ๐›๐š๐ฌ๐ค๐ž๐ญ ๐ฐ๐ข๐ญ๐ก ๐ง๐จ ๐ž๐ ๐ ๐ฌ.

Interviewer: Can Promise.all handle non-promise values.
Me: Yes, it will treat non-promise values as already resolved promises. So, if you pass a mix of promises and regular values, it will resolve with an array containing the resolved values.

Interviewer: Whatโ€™s the difference between Promise.all and Promise.allSettled?
Me: Promise.all stops as soon as one promise fails, while Promise.allSettled waits for all promises to complete, regardless of their outcomes. So, Promise.allSettled is like checking every egg in the basket to see if itโ€™s good or bad.

Interviewer: How does Promise.all improve performance in some scenarios?
Me: By running multiple promises concurrently rather than sequentially, Promise.all can significantly speed up tasks like making multiple API calls at once, compared to waiting for each one to finish before starting the next.

@Diyorbekk_dev
  • โœ 1
  • ๐Ÿ”ฅ 1
More from @diyorbekk_dev
  1. Sep 15, 2026ChatGPT and Codex now support TSRX syntax Highlighting! #tsrx #OctaneJS
  2. Sep 14, 2026Tanner Linsleydan yangilik. Hozirgacha Tanstack Team Octane uchun katta yordam berib kelmoโ€ฆ
  3. Sep 10, 2026Octane Js Hozirda Instagramda bitta content topoldim. Nasib tez kunda รฒzim yangiliklar qรฒyโ€ฆ
  4. Sep 9, 2026Ajoyib yangiliklardan biri. Tez orada Open AI butunlay รฒtadi nasib OctaneJsโ€™ga. Tarqatmayโ€ฆ
  5. Sep 5, 2026Yangi joyni ham tizimlashtirdik. Bir qancha yangi imkoniyatlar qoโ€˜shildi va yangi funksiyaโ€ฆ
  6. Sep 5, 2026photo post
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook โ†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 โ†’