在项目中需要对null、undefined进行判断有一下几种方法 进行比较运算时,对null及undefined加上引号if(data==="null"){ A; }else{ B; } 用!直接进行判断if(!data){}else{}