设为首页 加入收藏

TOP

JavaScript中 null\undefined\'' 小结
2015-08-31 21:25:03 来源: 作者: 【 】 浏览:36
Tags:JavaScript nullundefined' ' 小结

一、 前言


因为对java script中的 null\undefined\” 有些分不清楚,因此在试验之后进行一下小结。


二、 源码


? ? ? console.log(x);? ? ? ? ? //报错
? ? ? console.log(a);? ? ? ? ? //undefined
? ? ? console.log(b);? ? ? ? ? //null
? ? ? console.log(c.someva lue); //undefined
? ? ? console.log(d);? ? ? ? ? //
? ? ? console.log(!a, !b, !d);? //true true true
? ?
?
?
?


三、 总结
1.未定义变量: 使用会报错
2.声明变量未赋值: 变量为undefined
3.声明变量并赋值为null: 变量为null
4.对象中未声明的变量:变量为undefined
5.空字符串:变量为”
6.null\undefined\” 的非: 均为true


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇iOS中的事件传递和响应者链条 下一篇Python:在指定目录下查找满足条..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: