⬅️ Execute Program JavaScript Concurrency

new Promise(resolve => resolve(5));
 
// Async Result:
{fulfilled: 5}
 
new Promise((resolve, reject) => reject(new Error('it failed')));
 
// Async Result:
{rejected: 'Error: it failed'}
  • One important thing to keep in mind: the resolve function that we get from the constructor is separate from the Promise.resolve method. And the reject function here is separate from the Promise.reject method.