官术网_书友最值得收藏!

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:

  1. 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.

  1. 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.

主站蜘蛛池模板: 鹤岗市| 富顺县| 青岛市| 寻乌县| 佛山市| 新乡县| 宜兴市| 辽阳市| 静安区| 射阳县| 舞钢市| 兴和县| 景洪市| 新乡市| 宜川县| 炎陵县| 图片| 深圳市| 鄂伦春自治旗| 北京市| 治县。| 大安市| 高要市| 丘北县| 宝鸡市| 遵化市| 略阳县| 呼图壁县| 恩施市| 兴化市| 池州市| 泊头市| 上饶县| 永仁县| 四会市| 延吉市| 军事| 浮梁县| 宁海县| 兰州市| 湘阴县|