How to check undefined in Typescript

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

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

9条回答
  •  离开以前
    2021-02-04 23:33

    Use 'this' keyword to access variable. This worked for me

    var  uemail = localStorage.getItem("useremail");
    
    if (typeof this.uemail === "undefined")
    {
        alert('undefined');
    }
    else
    {
        alert('defined');
    }
    

提交回复
热议问题