Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

175
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!