JS Built-ins
Promisebeginner

Promise β€” executor does not have to resolve

πŸ“– Usage Example
const p = new Promise((resolve, reject) => {
  setTimeout(() => resolve(42), 100)
})
p.then(v => console.log(v))  // β†’ 42

The Promise constructor takes an executor function with resolve and reject callbacks to create a new promise.

Promise Pending

new Promise(() => {}) creates a pending Promise. It's still a Promise instance.

Challenge: Verify a pending Promise is still instanceof Promise.

πŸ’‘ Hints (1)
  • β€’ A Promise can be in a pending state β€” it is still a valid Promise.