Difficulty: 6/10asynchronous control flow, error handling, polyfill patternsPromise.all() settles when all promises are fullfilled and rejects as soon as first promise rejects.javascriptCopyScenario Questions0-2 years experience1We need a function that mimics Promise.all for an array of promises. How would you implement it in plain JavaScript?2If one of the promises passed to your polyfill rejects, what should the returned promise do, and how would you code that behavior?3What happens if the input array contains non‑promise values? Show how you'd handle that.Follow-up QuestionsHow would you test this polyfill across different browsers?What changes would you make to add a timeout or cancellation feature?How does your implementation behave when given an empty array?Suggest Improvement