判断一个值是否为null或者undefined

var a=null;
var b=undefined;
if(a===null){    //a==null
alert("a=null")
}else{
alert("a=no")
}//->a=null

if(b===undefined){  //b==undefined
alert("a=undefined")
}else{
alert("a=no")
}//->b=undefined

null与undefined是基本类型

注意:有些时候方法的返回值是"null"字符串而不是null。

6中基本类型:
    Undefined,Null,Boolean,String,Object,Number
 
扩展:jQuery中的is(selector)是遍历方法。只要有一个符合就为true。
 
 
 
 
原文地址:https://www.cnblogs.com/zqzjs/p/5060728.html