Fetching data from a server takes time. A synchronous request can leave the browser UI unresponsive; callbacks avoid that pause but make dependent requests and error handling awkward. A promise gives an asynchronous result a single object to work with: the value may arrive later, or the operation may fail. section 6.1 section 6.3
Create one with `new Promise(executor)`. The executor runs immediately and receives `resolve` and `reject` functions. Call `resolve(value)` when the work succeeds or `reject(reason)` when it fails. Register a success callback with `then`; supply a second callback or chain `catch` to handle rejection. section 6.3 section 6.3.3
A result that arrives later
`const result = new Promise((resolve, reject) => { setTimeout(() => resolve("Ready"), 500); }); result.then(value => console.log(value)).catch(error => console.log(error));` The executor sets up the timer immediately. The promise remains pending until the timer resolves it; the registered success callback handles the resulting value. section 6.3.2 section 6.3.3
A promise starts pending. It becomes fulfilled with a value or rejected with a reason, then stays in that state. Calling `reject` is not the only route to failure: an unhandled exception in the executor also rejects the promise. Both kinds of failure reach a rejection handler. section 6.3.2 section 6.3.3
A practical `getJSON(url)` can return a promise backed by `XMLHttpRequest`. Resolve it after a successful response has been parsed as JSON. Reject it for a communication error, an unsuccessful response status, or invalid JSON. The caller can then attach `then` and `catch` without managing those event handlers itself. section 6.3.4
For dependent requests, chain promises with `then`; for parallel asynchronous steps, use `Promise.all`. Promises can also work with generators: yield a promise while the generator pauses, then resume it when the result arrives. This keeps the browser from blocking while making a sequence of requests easier to follow. section 6.4 section 6.5






