Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

111
Vistas
Where is rejected property stored for a Promise in Javascript?

In the following code, the output clearly shows that rejected is within the created promise1 object. Yet when I look at MDN, there is no property indicating whether a promise is resolved or rejected. How does the program know whether a promise is accepted? Where is this information stored?

const promise1 = new Promise((resolve, reject) => {
  throw 'Uh-oh!';
});

console.log(promise1); //Promise { <rejected> 'Uh-oh!' }

promise1.catch((error) => {
  console.error(error);
});
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

If I correctly get the question, you ask about the cases upon which JS itself rejects the promise. A promise is rejected when an error is returned from the callback function. In general case you (the programmer) define the conditions which mean success or error according to the code business. Based on what you need, you can either throw or reject the promise and this Q&A looks helpful. But when a promise is gonna be used with a specific purpose, this behavior seems more clear, say when you use JS fetch api, there are solid situations in which the promise would be rejected.i.e. network disconnections or CORS errors. Here you can find a more detailed reply. These situations are those which are not biased towards any data transfer protocol such as HTTP. Finally, here, you can find a pretty well explained pattern for designing your promise workflow.

about 4 years ago · Juan Pablo Isaza Denunciar

0

There is no public API to check the Promise state, so there is no property that you could check.

Given the impossibility, you can try to do it on your own with any of these solutions:

https://ourcodeworld.com/articles/read/317/how-to-check-if-a-javascript-promise-has-been-fulfilled-rejected-or-resolved

https://github.com/nodejs/node/issues/40054#issuecomment-917641057

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda