Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
void在typescript中是什么意思?_Typescript - Fatal编程技术网

void在typescript中是什么意思?

void在typescript中是什么意思?,typescript,Typescript,我正在学习打字脚本,在一个教程中遇到了这个switch语句。我知道数字是分配给a的,所以所有参数都应该是数字。但是,虚空意味着什么,它做了什么 function switchFunction(a: number): void { switch (a) { case 1: let variableInCase1 = "test"; console.log(variableInCase1);

我正在学习打字脚本,在一个教程中遇到了这个switch语句。我知道数字是分配给a的,所以所有参数都应该是数字。但是,虚空意味着什么,它做了什么

function switchFunction(a: number): void {
    switch (a) {
        case 1:
            let variableInCase1 = "test";
            console.log(variableInCase1);
            break;
        case 2:
            let variableInCase2 = "test2";
            console.log(variableInCase2);
            break;
        default:
          console.log("Default");    
    }
}
switchFunction(1);
switchFunction(2);
switchFunction(3);

这意味着函数不需要返回值,这一点在没有
return
语句的事实中很明显。换句话说,该函数只能等同于
null
undefined


如果您希望函数执行操作,然后它将不返回任何内容