⬅️ 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 thePromise.resolve
method. And thereject
function here is separate from thePromise.reject
method.