Returning nothing with Void
Explore the void keyword in TypeScript to understand how it marks functions that return no value. Learn why explicitly setting a function's return type to void helps avoid errors by preventing unintended return values across multiple return statements.
We'll cover the following...
We'll cover the following...
Void means nothing. However, undefined can be assigned to void. The operation of setting undefined to void is not useful per se. However, a function that returns nothing should be marked with the reserved void keyword.
If a function is not explicitly marked with void as the return value, then by default, TypeScript will mark the return value as void. This may be problematic, because a programmer may return anything within the function. If it is explicitly set to void, ...