typescript / beginner
Snippet
The 'void' Return Type
In TypeScript, 'void' is used to indicate that a function does not return any value. It helps prevent logic errors where a return value might be expected but doesn't exist.
snippet.ts
1
2
3
function logAction(action: string): void {console.log('Action performed: ' + action);}
Breakdown
1
: void
Explicitly declares that the function does not return a result.