JS ⟩ async ⟩ Promise
⭐️ ES6 (2015) the future result of an async operation.
let p = promise.then(onFulfilled, onRejected)
if we have:
let p = promise.then(onResolved, onRejected)
we say p is:
resolved if onResolved() is called.
fulfilled if onResolved() returns a non-Promise value.
rejected if onRejected() is called.
onRejected()
settled if it's fulfilled or rejected.
pending if it's neither fulfilled nor rejected.
Any settled Promise has an associated value , which won't change.
using Promises
getJSON() - get JSON (Promise) from URL.
error handling
recoverable errors
finally()
chaining Promises
Promises in parallel
⭐️ ES2018 - for-await, finally()
await
await promises
Promise.wait()
Promise.inSeries()
async function
async method
JavaScript: The Definitive Guide (13.2 Promises)
amazon.jp ⟩ マンガでわかる JavaScript の Promisearrow-up-right (Kindle Cloud Readerarrow-up-right)
Promise.resolve()arrow-up-right
Promise.reject()arrow-up-right
Last updated 3 years ago