1.变量申明未赋值
var type; //type 变量未赋值
1. type==undefined //true
2. type===undefined //true
3. typeof(type)=='undefined' //true
4. typeof(type)==='undefined' //ture
5. typeof type == 'undefined' //和第3种等价,true
6. typeof type === 'undefined' //和第4种等价,true
7. type==null //true
8. type===null //false
注: typeof type 的值是"undefined",(typeof 返回的是字符串,有六种可能:"number"、"string"、"boolean"、"object"、"function"、"undefined")。
2.变量未申明
1. type1==undefined //Error: Uncaught ReferenceError: type1 is not defined at <anonymous>:1:1
2. type1===undefined //Error
3. typeof(type1)=='undefined' //true
4. typeof(type1)==='undefined' //ture
5. typeof type1 == 'undefined' //和第3种等价,true
6. typeof type1 === 'undefined' //和第4种等价,true
7. type1==null //Error: Uncaught ReferenceError: type1 is not defined at <anonymous>:1:1
8. type1===null //Error: Uncaught ReferenceError: type1 is not defined at <anonymous>:1:1
3.JavaScript undefined 属性
定义和用法
undefined 属性用于存放 JavaScript 的 undefined 值。
说明
无法使用 for/in 循环来枚举 undefined 属性,也不能用 delete 运算符来删除它。
undefined 不是常量,可以把它设置为其他值。
当尝试读取不存在的对象属性时也会返回 undefined。
提示和注释
提示:只能用 === 运算来测试某个值是否是未定义的,因为 == 运算符认为 undefined 值等价于 null。
注释:null 表示无值,而 undefined 表示一个未声明的变量,或已声明但没有赋值的变量,或一个并不存在的对象属性。

最新文章

  1. Hi, there!
  2. php ffmpeg
  3. UITextField实现左侧空出一定的边距
  4. CNContact对通讯录的基本使用(增删改查)
  5. css中的继承、层叠、样式优先级机制
  6. ASP.NET 上传图片添加文字、Logo水印
  7. POJ 3126 Prime Path 解题报告(BFS &amp; 双向BFS)
  8. ImageView一例
  9. ProxyCreationEnabled 和 LazyLoadingEnabled 的关系
  10. C#高级编程随笔
  11. 15个nosql
  12. CentOS7 部署 tomcat
  13. MySQL常见建表选项以约束
  14. vue调试工具vue-devtools安装及使用
  15. Redis docker安装和主要功能
  16. SpringBoot启动源码探究---getRunListener()
  17. SpringBoot------全局异常捕获和自定义异常
  18. VS Code 管理 .NET Core解决方案
  19. Java实现Socket通信
  20. Python Web学习笔记之多线程编程

热门文章

  1. Java:返回当前内存信息
  2. 网络编程——socket(四十三)
  3. c/c++ 整形转字符串
  4. 斯坦福大学公开课机器学习:监督学习在行人检测的应用(supervised learning for pedestrian detection)
  5. 错误:分析 EntityName 时出错 web配置
  6. 搭建Telnet服务器
  7. Python新手入门英文词汇笔记(转)
  8. JAVA记录-redis缓存机制介绍(三)
  9. HDU - 5117 Fluorescent(状压dp+思维)
  10. MSVCR120.dll丢失问题