TypeScript · Junior · Question 37 of 75
What does the return type void mean?
- ✓Correct answer: The function returns nothing useful; the result isn't used
- 2The function always returns
nullinstead of a value - 3The function never finishes or throws an error
Explanation
void is used for functions without a return value. Caveat: the callback type () => void allows passing a function that returns something (the result is ignored) - that's why arr.forEach(x => list.push(x)) compiles. A function that never finishes has the type never.