Understanding Promise.allSettled() in JavaScript

JavaScript Interview Question: What is Promise.allSettled()? Answer: Promise.allSettled() waits for all promises to finish regardless of success or failure. Example: 𝘗𝘳𝘰𝘮𝘪𝘴𝘦.𝘢𝘭𝘭𝘚𝘦𝘵𝘵𝘭𝘦𝘥([𝘱𝘳𝘰𝘮𝘪𝘴𝘦1, 𝘱𝘳𝘰𝘮𝘪𝘴𝘦2]) Explanation: It returns an array of objects describing each promise result. Follow-up Interview Question: When should you use Promise.allSettled() instead of Promise.all()? Answer: When you need results from all promises even if some fail. #javascript #promises #AsyncProgramming #WebDevelopment

To view or add a comment, sign in

Explore content categories