Prepare for the Salesforce JavaScript Developer Exam. Utilize comprehensive quizzes, flashcards, and multiple choice questions with hints and explanations. Boost your exam readiness!

Practice this question and more.


What are the internal properties of a promise object returned by the new Promise constructor?

  1. state and result

  2. status and error

  3. resolve and reject

  4. pending and fulfilled

The correct answer is: state and result

The internal properties of a promise object returned by the new Promise constructor are indeed "state" and "result." In the context of promises in JavaScript, the "state" property reflects the current status of the promise, which can be one of three values: pending, fulfilled (resolved), or rejected. The "result" property holds the value that the promise yields when it is fulfilled or the error if it is rejected. This understanding of the internal workings of promises is crucial for managing asynchronous operations effectively. It helps developers write code that can appropriately handle scenarios where asynchronous results are not immediately available, and it supports the implementation of logic based on whether a promise has succeeded or failed. The other options, while related to promises, do not accurately represent the internal properties of a promise. "Status" and "error" are more generic terms that do not reflect the specific properties structured within the promise object. The terms "resolve" and "reject," while important in the context of what a promise does, refer to the functions used to settle a promise rather than properties of the promise itself. Lastly, "pending" and "fulfilled" describe possible states of a promise but do not represent the actual properties used to manage a promise's state and result.