- Learn React with TypeScript 3
- Carl Rippon
- 99字
- 2021-06-10 19:16:32
Void
void is another type that doesn't exist in JavaScript. It is generally used to represent a non-returning function.
Let's look at an example:
- Let's enter the following function into the TypeScript playground:
function logText(text: string): void {
console.log(text);
}
The function simply logs some text into the console and doesn't return anything. So, we've marked the return type as void.
- If we remove the return type annotation and hover over the function name, logText, we'll see that TypeScript has inferred the type to be void:
This saves us a few keystrokes while writing functions that don't return anything.
推薦閱讀
- Qt 5 and OpenCV 4 Computer Vision Projects
- TypeScript入門與實戰(zhàn)
- 編程的修煉
- 測試驅(qū)動開發(fā):入門、實戰(zhàn)與進階
- Mastering phpMyAdmin 3.4 for Effective MySQL Management
- Developing Mobile Web ArcGIS Applications
- Mastering Articulate Storyline
- Architecting the Industrial Internet
- 微服務設計原理與架構
- OpenStack Cloud Computing Cookbook(Fourth Edition)
- Go語言開發(fā)實戰(zhàn)(慕課版)
- ExtJS Web應用程序開發(fā)指南第2版
- SciPy Recipes
- Scratch從入門到精通
- 深入淺出Python數(shù)據(jù)分析