Interview practice question
Typing a callback parameter
Frontend Engineering · TypeScript · Beginner
How would you type a function that accepts a callback, like a custom forEach?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Function type for callback ((item: T, index: number) => void).
- Generics to link item types.
- void return allows any return.
- Optional parameters in callback.
- Name types for reuse.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.