How can I determine if a variable is 'undefined' or 'null'?

前端 未结 30 2117
耶瑟儿~
耶瑟儿~ 2020-11-22 03:30

How do I determine if variable is undefined or null?

My code is as follows:

var EmpN         


        
30条回答
  •  暖寄归人
    2020-11-22 04:03

    The easiest way to check is:

    if(!variable) {
      // If the variable is null or undefined then execution of code will enter here.
    }
    

提交回复
热议问题