FlashKeepers

JavaScript · JavaScript

JavaScript Async Programming and ES6+ Features

Promises, async/await, arrow functions, and other modern ES6+ JavaScript features.

40 cards · basic cards · AI-written, checked twice. Edit anything.

Study this set free Look inside first Get FlashKeepers for iPhone
What is a Promise in JavaScript?
An object representing the eventual completion or failure of an asynchronous operation and its resulting value.
What are the three states a Promise can be in?
Pending, fulfilled (resolved), or rejected.
How do you create a new Promise?
Use the Promise constructor: new Promise((resolve, reject) => { ... })
What does the .then() method return?
A new Promise that resolves with the return value of the callback.
How do you handle Promise rejection with .catch()?
.catch(error => { ... }) runs if the Promise rejects, and receives the rejection reason.
What does .finally() do?
Runs code after a Promise settles, whether fulfilled or rejected, and returns a new Promise.
What does Promise.all() do?
Takes an array of Promises and returns a single Promise that resolves when all Promises resolve, or rejects if any reject.
What does Promise.race() do?
Takes an array of Promises and returns a Promise that resolves or rejects with the result of the first to settle.
What does Promise.resolve() do?
Returns a Promise that is already fulfilled with the given value.
What does Promise.reject() do?
Returns a Promise that is already rejected with the given reason.
What does the async keyword do?
Marks a function as asynchronous and makes it always return a Promise.
What does the await keyword do?
Pauses execution of an async function until a Promise settles and returns the resolved value.
What does an async function always return?
A Promise, even if the function returns a plain value.
How do you handle errors in an async function?
Use try/catch: try { ... } catch (error) { ... }
Can you await multiple Promises sequentially in an async function?
Yes, each await pauses execution until that Promise resolves before moving to the next.

25 more cards in the app