Break Arrays
π¨βπΌ Great work with arrays! You now know how to:
- π Create typed arrays with
Array<Type> - β Get type safety when adding elements
- π Iterate over arrays with
for...of - π Use union types for mixed arrays
π¦ Array types shine when combined with object types:
type User = { name: string; age: number }
const users: Array<User> = [
{ name: 'Alice', age: 30 },
{ name: 'Bob', age: 25 },
]
Next up: Tuplesβarrays with fixed length and specific types at each position!
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 2 using the epicshop MCP server. Call the get_quiz_instructions tool with exerciseNumber "2" to get the quiz instructions, then quiz me one question at a time.