Salesforce JavaScript Developer Practice Exam 2026 – Comprehensive Test Prep

Question: 1 / 400

Which Promise method correctly handles both resolve and reject?

Promise.then()

The Promise method that correctly handles both resolve and reject is represented by the first choice, which uses the `then()` method. The `then()` method takes two arguments: the first is a callback function that is executed when the Promise is resolved (successful completion), and the second is a callback function that is executed when the Promise is rejected (an error occurs). This dual capability allows `then()` to manage resolution and rejection, making it a powerful tool for asynchronous programming.

While the other methods serve important roles in working with Promises, they do not handle both outcomes in the same way. The `catch()` method specifically handles only the rejection of a Promise, allowing you to specify what happens when an error occurs. The `finally()` method allows you to execute code after a Promise settles (whether it resolves or rejects), but it does not provide a way to handle those outcomes separately. Lastly, `Promise.all()` is used to execute multiple Promises in parallel and is concerned with resolving when all provided Promises have resolved, but it does not directly manage individual resolve or reject cases.

The nature of `then()` in handling both scenarios makes it indispensably effective in Promise chaining and error handling.

Get further explanation with Examzify DeepDiveBeta

Promise.catch()

Promise.finally()

Promise.all()

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy