JavaScript null check

前端 未结 8 1014
小鲜肉
小鲜肉 2020-12-04 06:20

I\'ve come across the following code:

function test(data) {
    if (data != null && data !== undefined) {
        // some code here
    }
}
         


        
8条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-04 06:54

    var a;
    alert(a); //Value is undefined
    
    var b = "Volvo"; 
    alert(b); //Value is Volvo
    
    var c = null;
    alert(c); //Value is null
    

提交回复
热议问题