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

85
Views
Reference to Promise.all

This code works:

Promise.all([Promise.resolve(1)])

However, this code does not:

const f = Promise.all

f([Promise.resolve(1)])

The second piece of code throws the following error: Uncaught TypeError: Promise.all called on non-object.

Why can't I assign the function Promise.all to a variable and use it as normal?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Because that's what the spec requires.

1. Let C be the this value.
2. Let promiseCapability be ? NewPromiseCapability(C).
3. Let promiseResolve be Completion(GetPromiseResolve(C)).
...

The all function requires its this value to be a constructor function that supports the parameter conventions of the Promise constructor.

Your current code is not calling the function as part of an object (that is, f is a standalone identifier), so the resulting this is either the global object or undefined, depending on whether you're in strict mode or not - either way, the above requirement is not fulfilled.

If you bind the function to Promise, it'll work.

const f = Promise.all.bind(Promise);
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!