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

179
Vistas
Javascript Promise: is the method name for resolve and reject arbitrary?

I am confused on the concepts of Promise, Resolve, Reject, then, catch.

While I know how to write code that works, I want to clarify some questions:

Question 1: Regarding Resolve, Reject, then, catch, Are these methods all introduced together with Promise? Before Promise is introduced to Javascript, does Javascript already have these special methods?

Question 2: Are the method names resolve, reject that are passed as parameters to executor functions in Promise arbitrary? For example:

const executorFunction = (resolve, reject) => {
  if ('1' === '1') {
      resolve('I resolved!');
  } else {
      reject('I rejected!'); 
  }
}
const myFirstPromise = new Promise(executorFunction);

This above code works well, no syntax error or anything. The promise will be in fulfilled state with 'I resolved!' value. But if I do:

const executorFunction = (A, B) => {
  if ('1' === '1') {
      A('I resolved!');
  } else {
      B('I rejected!'); 
  }
}
const myFirstPromise = new Promise(executorFunction);

Would it still work? Will the promise still be in fulfilled state with 'I resolved!' value?

And to make it further, if I swap the method names:

const executorFunction = (reject, resolve) => {
  if ('1' === '1') {
      reject('I resolved!');
  } else {
      resolve('I rejected!'); 
  }
}
const myFirstPromise = new Promise(executorFunction);

Now, would this work? Will the promise still be in fulfilled state with 'I resolved!' value?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

  1. Promise is an object spec that was included with Javascript. Before Promise was included as part of Javascript, the same spec could be built via code.
  2. Executor function is a function. Hence, it doesn't matter what the parameters are called, just their order.
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