How to check undefined in Typescript

前端 未结 9 970
面向向阳花
面向向阳花 2021-02-04 23:05

I am using this code to check undefined variable but it\'s not working.

9条回答
  •  执念已碎
    2021-02-04 23:34

    In Typescript 2 you can use Undefined type to check for undefined values. So if you declare a variable as:

    let uemail : string | undefined;
    

    Then you can check if the variable z is undefined as:

    if(uemail === undefined)
    {
    
    }
    

提交回复
热议问题