js null,'0','unfined'
来源:互联网 发布:显示器色彩测试软件 编辑:程序博客网 时间:2024/06/07 06:13
首先
typeof(undefined) == 'undefined'
typeof(null) == 'object'
typeof("") == 'string'
typeof(0) == 'number'
typeof(false) == 'boolean'
这五个值的共同点是,在if语句中做判断,都会执行false分支。当然从广义上来看,是说明这些数值都是其对应数据类型上的无效值或空值。还有这五个值作!运算,结果全为:true。
然后
var o={flag:true}; var test=!!o.flag;//等效于var test=o.flag||false; 不为空则为falsealert(test);
由于对null与undefined用!操作符时都会产生true的结果,所以用两个感叹号的作用就在于,如果明确设置了o中flag的值(非 null/undefined/0""/等值),自然test就会取跟o.flag一样的值;如果没有设置,test就会默认为false,而不是 null或undefined。
- js null,'0','unfined'
- js 阻止冒泡,ajax 同步, unfined 类型判断 ,checkBox 全选
- js null undefined 0
- 区分JS中的null,undefined,'',0,false
- JS中null,false,0,""和undefined
- js 中 undefined、null、""、0、false
- js中null与0的比较
- JS如何判断undefined,null,0
- JS !=null
- JS !=null
- Null与Undefined JS
- JS:Undefined 和 Null
- js: null & undefined
- js undefined & null
- JS null问题
- js ajax null验证
- js if null undifined
- js--null和undefined
- 数据结构学习笔记(二)各种排序
- 如何对directive进行单元测试?
- Action 动作
- sql查找表中列的属性
- UTMS 信令培训(1)
- js null,'0','unfined'
- CSS选择器
- 一天一linux命令(15) history 历史命令
- hive表乱码问题
- cocos2d-x 颜色混合
- 怎样测试返回是promise的service
- tablet systemUI修改
- 吉哥系列故事——临时工计划 hdu 4502
- 画出自己的UI组件