Spider024

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2013年3月26日

摘要: 一般如果变量通过var声明,但是并未初始化的时候,变量的值为undefined,而未定义的变量则需要通过 "typeof 变量"的形式来判断,否则会发生错误。例如:if(!myVar01)alert("发生错误"); // 该代码直接发生异常,因为变量myVar01没有申明 if("undefined" == typeof myVar01)alert("发生错误"); // 这样写才不至于发生异常而: var myVar01; if(undefined == myVar01)alert("发生错误&quo 阅读全文
posted @ 2013-03-26 14:27 Spider024 阅读(965) 评论(1) 推荐(0) 编辑