Break Promises
π¨βπΌ Excellent! You now understand how to create and work with Promises.
You learned:
- π¨ Creating Promises with
new Promise() - π Chaining operations with
.then() - β οΈ Error handling with
.catch() - π― Type safety with
Promise<T>generic types
π¦ Remember: Promises are eagerβthey start executing immediately when created.
If you need lazy execution, wrap the Promise creation in a function.
// Eager - starts immediately
const promise = fetchData()
// Lazy - starts when function is called
const getPromise = () => fetchData()
Next up: Async/awaitβa cleaner syntax for working with Promises!
Test Your Knowledge
Retrieval practice helps solidify learning by actively recalling information. Use this prompt with your AI assistant to quiz yourself on what you've learned.
Please quiz me on exercise 1 using the epicshop MCP server. Call the get_quiz_instructions tool with exerciseNumber "1" to get the quiz instructions, then quiz me one question at a time.