Quiz · 3 questions
🪝 Functions — Where Most Beginner Pain Lives
Function types, overloads, arrow vs declared, this typing, contextual typing
Level 0Curious
0 XP0/93 lessons0/23 achievements
0/100 XP to next level100 XP to go0% complete
Quiz
01What does
(e: Event) => void mean as a function type?Hint
Compare this to a parameter typed
: undefined, which would only allow explicit returns of undefined.02When should you use a function overload signature?
Hint
If you can express the relationship between arguments and return with
function f<T>(x: T): T extends string ? number : string, generics + conditional types is usually cleaner than overloads.03What's the real difference between an arrow function and a function declaration?
Hint
Try
setTimeout(this.handler, 1000) vs setTimeout(() => this.handler(), 1000). The first loses this; the second preserves it.Comments 0
🔔 Reply notifications (sign in)Sign in — Please sign in to comment.
No comments yet — be the first.