2018年的文章移至github上,点我去!2018年的文章移至github上,点我去!2018年的文章移至github上,点我去!

Fork me on GitHub

判断一个值是否为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。
 
 
 
 

posted on 2015-12-20 13:27  qize  阅读(1529)  评论(0编辑  收藏  举报

导航